PozdravljenSvet
Iz Wikipedije, proste enciklopedije
Program PozdravljenSvet (tudi ZivijoSvet) je kratek računalniški program, ki ilustrira uporabo nekega programskega jezika. Programček izpiše na zaslon besedilo »Pozdravljen svet!« (v angleški različici »Hello, world!«).
Program je uporabljen v mnogih (če ne vseh) uvodnih poglavjih knjig o učenju programiranja. Prvič naj bi se pojavil v knjigi The C Programming Language, (Brian Kernighan in Dennis Ritchie, 1978):
main( ) {
printf("Hello, world!");
}
Primeri v različnih programskih jezikih:
[uredi] Črkovni vmesniki (konzola)
[uredi] ABC
WRITE "'Pozdravljen svet!'"
[uredi] Ada
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line ("Pozdravljen svet!");
end Hello;
Glejte wikibooks:Programming:Ada:Basic.
[uredi] AmigaE
PROC main()
WriteF('Pozdravljen svet!')
ENDPROC
[uredi] APL
'Pozdravljen svet!'
[uredi] Zbirnik
[uredi] First successful µP/OS combinations: Intel 8080/Zilog Z80, CP/M, RMAC assembler
bdos equ 0005H ; BDOS entry point
start: mvi c,9 ; BDOS function: output string
lxi d,msg$ ; address of msg
call bdos
ret ; return to CCP
msg$: db 'Pozdravljen svet!$'
end start
[uredi] Accumulator + index register machine: MOS Technology 6502, CBM KERNAL, ca65 assembler
MSG: .ASCIIZ "Pozdravljen svet!"
LDX #0
LDA MSG,X ; load initial char
@LP: JSR $FFD2 ; chrout
INX
LDA MSG,X
BNE @LP
RTS
[uredi] Expanded accumulator machine: Intel x86, DOS, TASM
MODEL SMALL
IDEAL
STACK 100H
DATASEG
MSG DB 'Pozdravljen svet!', 13, '$'
CODESEG
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET MSG
MOV AH, 09H ; DOS: output ASCII$ string
INT 21H
MOV AX, 4C00H
INT 21H
END
[uredi] Expanded accumulator machine: Intel x86, Linux, GAS
.data
msg:
.ascii "Pozdravljen svet!\n"
len = . - msg
.text
.global _start
_start:
movl $len,%edx
movl $msg,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
movl $1,%eax
int $0x80
[uredi] General-purpose fictional computer: MIX, MIXAL
TERM EQU 19 console device no. (19 = typewriter)
ORIG 1000 start address
START OUT MSG(TERM) output data at address MSG
HLT halt execution
MSG ALF "HELLO"
ALF " WORL"
ALF "D "
END START end of program
[uredi] General-purpose fictional computer: MMIX, MMIXAL
Main GETA $255,string get the address of the string in register 255
TRAP 0,Fputs,StdOut put the string pointed to by register 255 to file StdOut
string BYTE "Pozdravljen svet!",#a,0 string to be printed (#a is newline and 0 terminates the string)
TRAP 0,Halt,0 end process
[uredi] General-purpose-register CISC: DEC PDP-11, RT-11, MACRO-11
.MCALL .REGDEF,.TTYOUT,.EXIT
.REGDEF
HELLO: MOV #MSG,R1
MOVB (R1),R0
LOOP: .TTYOUT
MOVB +(R1),R0
BNE LOOP
.EXIT
MSG: .ASCIZ /Pozdravljen svet!/
.END HELLO
[uredi] CISC on advanced multiprocessing OS: DEC VAX, VMS, MACRO-32
.title hello
.psect data, wrt, noexe
chan: .blkw 1
iosb: .blkq 1
term: .ascid "SYS$OUTPUT"
msg: .ascii "Pozdravljen svet!"
len = . - msg
.psect code, nowrt, exe
.entry hello, ^m<>
; Establish a channel for terminal I/O
$assign_s devnam=term, -
chan=chan
blbc r0, end
; Queue the I/O request
$qiow_s chan=chan, -
func=#io$_writevblk, -
iosb=iosb, -
p1=msg, -
p2=#len
; Check the status and the IOSB status
blbc r0, end
movzwl iosb, r0
; Return to operating system
end: ret
.end hello
[uredi] RISC processor: ARM, RISC OS, BBC BASIC's in-line assembler
.program
ADR R0,message
SWI "OS_Write0"
SWI "OS_Exit"
.message
DCS "Pozdravljen svet!"
DCB 0
ALIGN
ali krajša verzija (iz qUE);
SWI"OS_WriteS":EQUS"Pozdravljen svet!":EQUB0:ALIGN:MOVPC,R14
[uredi] AWK
BEGIN { print "Pozdravljen svet!" }
[uredi] bash
Zelo podobno je tudi v ostalih lupinah, potrebno je le ustrezno popraviti pot v prvi vrstici.
#!/usr/local/bin/bash echo "Pozdravljen svet!"
[uredi] BASIC
10 PRINT "Pozdravljen svet!" 20 END
ali
PRINT "Pozdravljen svet!" END
[uredi] TI-BASIC
Na kalkulatorji Texas Instruments, serije od TI-80 do TI-86:
:Disp "Pozdravljen svet!" ali :Output(1,1,"Pozdravljen svet!")
Ali preprosto:
:"Pozdravljen svet!"
Na TI-89/TI-92 kalkulatorjih:
:hellowld() :Prgm :Disp "Pozdravljen svet!" :EndPrgm
[uredi] StarOffice/OpenOffice Basic
sub main
print "Pozdravljen svet!"
end sub
[uredi] Visual Basic
To output to the debug console:
Debug.Print "Pozdravljen svet!"
To output a message box to the user:
VBA.Interaction.MsgBox "Pozdravljen svet!"
[uredi] BCPL
GET "LIBHDR"
LET START () BE
$(
WRITES ("Pozdravljen svet!*N")
$)
[uredi] BLISS
%TITLE 'HELLO_WORLD'
MODULE HELLO_WORLD (IDENT='V1.0', MAIN=HELLO_WORLD,
ADDRESSING_MODE (EXTERNAL=GENERAL)) =
BEGIN
LIBRARY 'SYS$LIBRARY:STARLET';
EXTERNAL ROUTINE
LIB$PUT_OUTPUT;
GLOBAL ROUTINE HELLO_WORLD =
BEGIN
LIB$PUT_OUTPUT(%ASCID %STRING('Pozdravljen svet!'))
END;
END
ELUDOM
[uredi] boo
print "Pozdravljen svet!"
[uredi] Casio fx-7950
Ta program deluje na fx-9750 grafičnih kalkulatorjih in njemu kompatibilnih.
"Pozdravljen svet!"←'
[uredi] C
#include <stdio.h>
int main(void)
{
printf("Pozdravljen svet!\n");
return 0;
}
[uredi] C#
using System;
class HelloWorldApp
{
public static void Main()
{
Console.WriteLine("Pozdravljen svet!");
}
}
[uredi] C++
#include <iostream>
int main()
{
std::cout << "Pozdravljen svet!" << std::endl;
}
[uredi] C++, Managed
#using <mscorlib.dll>
using namespace System;
int wmain()
{
Console::WriteLine("Pozdravljen svet!");
}
[uredi] ColdFusion (CFM)
<cfoutput> Pozdravljen svet! </cfoutput>
[uredi] COMAL
PRINT "Pozdravljen svet!"
[uredi] CIL
.method public static void Main() cil managed
{
.entrypoint
.maxstack 8
ldstr "Pozdravljen svet!"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
[uredi] Clean
module hello Start = "Pozdravljen svet!"
[uredi] CLIST
PROC 0 WRITE Pozdravljen svet!
[uredi] COBOL
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. ENVIRONMENT DIVISION. DATA DIVISION. PROCEDURE DIVISION. DISPLAY "Pozdravljen svet!". STOP RUN.
[uredi] Common Lisp
(format t "Pozdravljen svet!~%")
ali
(write-line "Pozdravljen svet!")
[uredi] D
import std.stdio;
void main()
{
writefln("Pozdravljen svet!");
}
[uredi] DCL batch
$ write sys$output "Pozdravljen svet!"
[uredi] Dylan
module: hello
format-out("Pozdravljen svet!\n");
[uredi] Ed and Ex (Ed extended)
a Pozdravljen svet! . p
ali tako:
echo -e 'a\nPozdravljen svet!\n.\np'|ed echo -e 'a\nPozdravljen svet!\n.\np'|ex
[uredi] Eiffel
class HELLO_WORLD
creation
make
feature
make is
local
io:BASIC_IO
do
!io
io.put_string("%N Pozdravljen svet!")
end -- make
end -- class HELLO_WORLD
[uredi] Erlang
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("Pozdravljen svet!\n").
[uredi] Euphoria
puts(1, "Pozdravljen svet!")
[uredi] F#
type data =
{ first: string;
second: string; }
let myData =
{ first="Hello";
second="world"; }
let _ =
print_string myData.first;
print_string " ";
print_string myData.second;
print_newline()
[uredi] Focus
-TYPE Pozdravljen svet!
[uredi] Forte TOOL
begin TOOL HelloWorld;
includes Framework;
HAS PROPERTY IsLibrary = FALSE;
forward Hello;
-- START CLASS DEFINITIONS
class Hello inherits from Framework.Object
has public method Init;
has property
shared=(allow=off, override=on);
transactional=(allow=off, override=on);
monitored=(allow=off, override=on);
distributed=(allow=off, override=on);
end class;
-- END CLASS DEFINITIONS
-- START METHOD DEFINITIONS
------------------------------------------------------------
method Hello.Init
begin
super.Init();
task.Part.LogMgr.PutLine('HelloWorld!');
end method;
-- END METHOD DEFINITIONS
HAS PROPERTY
CompatibilityLevel = 0;
ProjectType = APPLICATION;
Restricted = FALSE;
MultiThreaded = TRUE;
Internal = FALSE;
LibraryName = 'hellowor';
StartingMethod = (class = Hello, method = Init);
end HelloWorld;
[uredi] Forth
." Pozdravljen svet!" CR
[uredi] FORTRAN
PROGRAM HELLO
PRINT *, 'Pozdravljen svet!'
END
[uredi] Frink
println["Pozdravljen svet!"]
[uredi] Gambas
Poglejte tudi GUI kategorijo.
PUBLIC SUB Main()
Print "Pozdravljen svet!"
END
[uredi] Game Maker
V dogodku risanja določenega predmeta:
draw_text(x,y,"Pozdravljen svet!")
Ali da prikaže pogovorno okno s sporočilom:
show_message("Pozdravljen svet!")
[uredi] Haskell
module Main (main) where main = putStr "Pozdravljen svet!\n"
ali
main = putStr "Pozdravljen svet!\n"
[uredi] Heron
program HelloWorld;
functions {
_main() {
print_string("Pozdravljen svet!");
}
}
end
[uredi] HP-41 & HP-42S
(Handheld Hewlett-Packard RPN-based alphanumeric engineering calculators.)
01 LBLTHELLO 02 TPozdravljen svet! 03 PROMPT
[uredi] HyperTalk (Apple HyperCard's scripting language)
put "Pozdravljen svet!"
ali
Answer "Hello, world!"
[uredi] IDL
print,"Pozdravljen svet!"
[uredi] Inform
[ Main;
print "Pozdravljen svet!^";
];
[uredi] Io
"Pozdravljen svet!" print
ali
write("Pozdravljen svet!\n")
[uredi] Iptscrae
ON ENTER {
"Hello, " "World!" & SAY
}
[uredi] Java
Glej tudi GUI sekcijo.
public class Hello {
public static void main(String[] args) {
System.out.println("Pozdravljen svet!");
}
}
[uredi] JVM
(disassembler output of javap -c Hello.class)
public class Hello extends java.lang.Object {
public Hello();
public static void main(java.lang.String[]);
}
Method Hello()
0 aload_0
1 invokespecial #1 <Method java.lang.Object()>
4 return
Method void main(java.lang.String[])
0 getstatic #2 <Field java.io.PrintStream out>
3 ldc #3 <String "Pozdravljen svet!">
5 invokevirtual #4 <Method void println(java.lang.String)>
8 return
[uredi] Kogut
WriteLine "Pozdravljen svet!"
[uredi] Logo
print [Pozdravljen svet!]
ali
pr [Pozdravljen svet!]
Edino v mswlogo:
messagebox [Hi] [Pozdravljen svet!]
[uredi] Lua
print "Pozdravljen svet!"
[uredi] M (MUMPS)
W "Pozdravljen svet!"
[uredi] Macsyma, Maxima
print("Pozdravljen svet!")$
[uredi] Maple
print("Pozdravljen svet!");
[uredi] Mathematica
Print["Pozdravljen svet!"]
[uredi] MATLAB
disp('Pozdravljen svet!')
[uredi] Max
max v2; #N vpatcher 10 59 610 459; #P message 33 93 63 196617 Pozdravljen svet!; #P newex 33 73 45 196617 loadbang; #P newex 33 111 31 196617 print; #P connect 1 0 2 0; #P connect 2 0 0 0; #P pop;
[uredi] Modula-2
MODULE Hello;
FROM Terminal2 IMPORT WriteLn; WriteString;
BEGIN
WriteString("Pozdravljen svet!");
WriteLn;
END Hello;
[uredi] MS-DOS batch
(with the standard command.com interpreter. The @ symbol is optional and prevents the system from repeating the command before executing it. The @ symbol must be omitted on versions of MS-DOS prior to 3.0.)
@echo Pozdravljen svet!
[uredi] MUF
: main
me @ "Pozdravljen svet!" notify
;
[uredi] Natural
WRITE "Pozdravljen svet!" END
[uredi] Ncurses
#include <ncurses.h>
int main()
{
initscr();
printw("Pozdravljen svet!");
refresh();
getch();
endwin();
return 0;
}
[uredi] Oberon
MODULE Hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
PROCEDURE World*;
BEGIN
Texts.WriteString(W, "Pozdravljen svet!");
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END World;
BEGIN
Texts.OpenWriter(W)
END Hello.
[uredi] Objective C
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSLog(@"Pozdravljen svet!");
return 0;
}
[uredi] OCaml
print_endline "Pozdravljen svet!"
[uredi] OPL
Glej tudi GUI sekcijo.
PROC hello:
PRINT "Pozdravljen svet!"
ENDP
[uredi] OPS5
(object-class request
^action)
(startup
(strategy MEA)
(make request ^action hello)
)
(rule hello
(request ^action hello)
-->
(write |Pozdravljen svet!| (crlf))
)
[uredi] Pascal
Program Hello;
begin
WriteLn('Pozdravljen svet!');
end.
[uredi] Perl
print "Pozdravljen svet!\n";
(To je prvi primer knjige Learning Perl.)
[uredi] PHP
<?php echo "Pozdravljen svet!\n"; ?>
ali
<?="Pozdravljen svet!\n" ?>
vendar je to poblj priporočljivo:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>Pozdravljen svet!</title> </head> <body> <?php echo "Pozdravljen svet!"; ?> </body> </html>
[uredi] Pike
int main() {
write("Pozdravljen svet!\n");
return 0;
}
[uredi] PL/SQL
procedure print_hello_world as
dbms_output.enable(1000000);
dbms_output.put_line("Pozdravljen svet!");
end print_hello_world;
[uredi] PL/I
Test: proc options(main) reorder;
put skip edit('Pozdravljen svet!') (a);
end Test;
[uredi] POP-11
'Pozdravljen svet!' =>
[uredi] POV-Ray
#include "colors.inc"
camera {
location <3, 1, -10>
look_at <3,0,0>
}
light_source { <500,500,-1000> White }
text {
ttf "timrom.ttf" "Pozdravljen svet!" 1, 0
pigment { White }
}
[uredi] Processing
println("Pozdravljen svet!");
[uredi] Prolog
write('Pozdravljen svet!'),nl.
[uredi] Python
print "Pozdravljen svet!"
[uredi] REXX, NetRexx, and Object REXX
say "Pozdravljen svet!"
[uredi] RPL
Glej tudi GUI sekcijo.
(Na Hewlett-Packard grafičnih kalkulatorjih, serije HP-28, HP-48 in HP-49.)
<<
CLLCD
"Pozdravljen svet!" 1 DISP
0 WAIT
DROP
>>
[uredi] Ruby
Glej tudi GUI sekcijo.
puts "Pozdravljen svet!"
[uredi] SAS
data _null_; put 'Pozdravljen svet!'; run;
[uredi] Sather
class HELLO_WORLD is
main is
#OUT+"Pozdravljen svet!\n";
end;
end;
[uredi] Scala
object HelloWorld with Application {
Console.println("Pozdravljen svet!");
}
[uredi] Scheme
(display "Pozdravljen svet!") (newline)
[uredi] sed
(Opozorilo: potrebuje najmanj eno vrstico vhoda)
sed -ne '1s/.*/Pozdravljen svet!/p'
[uredi] Seed7
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln("Pozdravljen svet!");
end func;
[uredi] Self
'Pozdravljen svet!' print.
[uredi] Simula
BEGIN
OutText("Pozdravljen svet!");
OutImage;
END
[uredi] Smalltalk
Transcript show: 'Pozdravljen svet!'; cr
[uredi] SML
print "Pozdravljen svet!\n";
[uredi] SNOBOL
OUTPUT = "Pozdravljen svet!"
END
[uredi] SPARK
with Spark_IO;
--# inherit Spark_IO;
--# main_program;
procedure Hello_World
--# global in out Spark_IO.Outputs;
--# derives Spark_IO.Outputs from Spark_IO.Outputs;
is
begin
Spark_IO.Put_Line (Spark_IO.Standard_Output, "Pozdravljen svet!", 0);
end Hello_World;
[uredi] SPITBOL
OUTPUT = "Pozdravljen svet!"
END
[uredi] SQL
CREATE TABLE `message` (`text` char(15));
INSERT INTO `message` (`text`) VALUES ('Pozdravljen svet!');
SELECT `text` FROM `message`;
DROP TABLE `message`;
ali (Oracleov dialekt)
SELECT 'Pozdravljen svet!' FROM dual;
ali (for Oracle's PL/SQL proprietary procedural language)
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('Pozdravljen svet!, from PL/SQL');
END;
ali (MySQL in PostgreSQL dialekt)
SELECT 'Pozdravljen svet!';
ali (T-SQL dialekt)
PRINT 'Pozdravljen svet!'
ali (KB-SQL dialekt)
select Null from DATA_DICTIONARY.SQL_QUERY FOOTER or HEADER or DETAIL or FINAL event write "Pozdravljen svet!"
[uredi] STARLET
RACINE: HELLO_WORLD.
NOTIONS:
HELLO_WORLD : ecrire("Pozdravljen svet!").
[uredi] TACL
#OUTPUT Pozdravljen svet!
[uredi] Tcl (Tool command language)
Glej tudi GUI sekcijo.
puts "Pozdravljen svet!"
[uredi] Turing
put "Pozdravljen svet!"
[uredi] TSQL
Declare @Output varchar(16) Set @Output='Pozdravljen svet!' Select @Output
ali preprostejši način:
Select 'Pozdravljen svet!' Print 'Pozdravljen svet!'
[uredi] UNIX-style shell
echo 'Pozdravljen svet!'
ali
printf 'Pozdravljen svet!\n'
or for a curses interface:
dialog --msgbox "Pozdravljen svet!" 0 0
[uredi] Grafični vmesniki (GUI)
[uredi] ActionScript (Macromedia Flash MX)
trace ("Pozdravljen svet!")
[uredi] AppleScript
display dialog "Pozdravljen svet!"
Or to have the OS synthesize it and literally say "Pozdravljen svet!" (with no comma, as that would cause the synthesizer to pause)
say "Pozdravljen svet!"
[uredi] Cocoa ali GNUStep (v objektivnem C-ju)
#import <Cocoa/Cocoa.h>
@interface hello : NSObject {
}
@end
@implementation hello
-(void)awakeFromNib
{
NSBeep(); // we don't need this but it's conventional to beep
// when you show an alert
NSRunAlertPanel(@"Message from your Computer", @"Pozdravljen svet!", @"Hi!",
nil, nil);
}
@end
[uredi] Delphi, Kylix
ShowMessage("Pozdravljen svet!");
[uredi] FLTK2 (v C++)
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/run.h>
using namespace fltk;
int main(int argc, char **argv)
{
Window *window = new Window(300, 180);
window->begin();
Widget *box = new Widget(20, 40, 260, 100, "Pozdravljen svet!");
box->box(UP_BOX);
box->labelfont(HELVETICA_BOLD_ITALIC);
box->labelsize(36);
box->labeltype(SHADOW_LABEL);
window->end();
window->show(argc, argv);
return run();
}
[uredi] Gambas
Glej tudi TUI sekcijo.
PUBLIC SUB Main()
Message.Info("Pozdravljen svet!")
END
[uredi] GTK toolkit (v C++)
#include <iostream>
#include <gtkmm/main.h>
#include <gtkmm/button.h>
#include <gtkmm/window.h>
using namespace std;
class HelloWorld : public Gtk::Window {
public:
HelloWorld();
virtual ~HelloWorld();
protected:
Gtk::Button m_button;
virtual void on_button_clicked();
};
HelloWorld::HelloWorld()
: m_button("Pozdravljen svet!") {
set_border_width(10);
m_button.signal_clicked().connect(SigC::slot(*this,
&HelloWorld::on_button_clicked));
add(m_button);
m_button.show();
}
HelloWorld::~HelloWorld() {}
void HelloWorld::on_button_clicked() {
cout << "Pozdravljen svet!" << endl;
}
int main (int argc, char *argv[]) {
Gtk::Main kit(argc, argv);
HelloWorld helloworld;
Gtk::Main::run(helloworld);
return 0;
}
[uredi] GTK# (v C#)
using Gtk;
using GtkSharp;
using System;
class Hello {
static void Main()
{
Application.Init ();
Window window = new Window ("helloworld");
window.Show();
Application.Run ();
}
}
[uredi] GTK 2.x (v Euphoria)
include gtk2/wrapper.e Info(NULL,"Hello","Pozdravljen svet!")
[uredi] Java
Glej tudi TUI sekcija.
import javax.swing.JOptionPane;
public class Hello {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "Pozdravljen svet!");
}
}
[uredi] Java applet
Programčki, napisani v Javi, delujejo tudi v HTML datotekah.
<HTML> <HEAD> <TITLE>Pozdravljen svet!</TITLE> </HEAD> <BODY> Program Pozdravljen svet! pravi: <APPLET CODE="HelloWorld.class" WIDTH=600 HEIGHT=100></APPLET> </BODY> </HTML>
import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Pozdravljen svet!", 100, 50);
}
}
[uredi] JavaScript and JScript
- JavaScript (an implementation of ECMAScript) is a client-side scripting language used in HTML files. The following code can be placed in any HTML file:
<script type="text/javascript"><!--
function helloWorld()
{
alert("Pozdravljen svet!");
}
//--></script>
<a href="#" onclick="helloWorld(); return false;">Pozdravljen svet! Example</a>
- An easier method uses JavaScript implicitly, directly calling the reserved alert function. Cut and paste the following line inside the <body> .... </body> HTML tags.
<a href="#" onclick="alert('Pozdravljen svet!'); return false;">Pozdravljen svet! Example
</a>
- An even easier method involves using popular browsers' support for the virtual 'javascript' protocol to execute JavaScript code. Enter the following as an Internet address (usually by pasting into the address box):
javascript:alert('Pozdravljen svet!');
- There is an almost infinite number of ways to do it:
javascript:document.write('Pozdravljen svet!\n');
[uredi] OPL
See also TUI section.
(On Psion Series 3 and later compatible PDAs.)
PROC guihello:
ALERT("Pozdravljen svet!","","Exit")
ENDP
ali
PROC hello:
dINIT "Naslov okna"
dTEXT "","Pozdravljen svet!"
dBUTTONS "OK",13
DIALOG
ENDP
[uredi] Qt toolkit (in C++)
#include <qapplication.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <iostream>
class HelloWorld : public QWidget
{
Q_OBJECT
public:
HelloWorld();
virtual ~HelloWorld();
public slots:
void handleButtonClicked();
QPushButton *mPushButton;
};
HelloWorld::HelloWorld() :
QWidget(),
mPushButton(new QPushButton("Pozdravljen svet!", this))
{
connect(mPushButton, SIGNAL(clicked()), this, SLOT(handleButtonClicked()));
}
HelloWorld::~HelloWorld() {}
void HelloWorld::handleButtonClicked()
{
std::cout << "Pozdravljen svet!" << std::endl;
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
HelloWorld helloWorld;
app.setMainWidget(&helloWorld);
helloWorld.show();
return app.exec();
}
[uredi] REALbasic
MsgBox "Pozdravljen svet!"
[uredi] RPL
Glej tudi TUI sekcijo.
(Na Hewlett-Packard grafičnih kalkulatorjih serije HP-48G in HP-49G.)
<< "Pozdravljen svet!" MSGBOX >>
[uredi] RTML
Hello () TEXT "Pozdravljen svet!"
[uredi] SWT
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
public class SWTHello {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
RowLayout layout = new RowLayout();
layout.justify = true;
layout.pack = true;
shell.setLayout(layout);
shell.setText("Pozdravljen svet!");
Label label = new Label(shell, SWT.CENTER);
label.setText("Pozdravljen svet!");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
[uredi] Tcl/Tk
Glej tudi TUI kategorijo.
label .l -text "Pozdravljen svet!" pack .l
[uredi] Visual Basic vključuje VBA
Sub Main()
MsgBox "Pozdravljen svet!"
End Sub
[uredi] Windows API (v C)
#include <windows.h>
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[] = "MainWnd";
HINSTANCE hInstance;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wincl;
hInstance = hInst;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.style = 0;
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpszMenuName = NULL; //No menu
wincl.lpfnWndProc = WindowProcedure;
wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); //Color of the window
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon
wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor
if (!RegisterClassEx(&wincl))
return 0;
hwnd = CreateWindowEx(0, //No extended window styles
szClassName, //Class name
"", //Window caption
WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top
//positions of the window
120, 50, //Width and height of the window,
NULL, NULL, hInstance, NULL);
//Make the window visible on the screen
ShowWindow(hwnd, nCmdShow);
//Run the message loop
while (GetMessage(&msg, NULL, 0, 0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 15, 3, "Pozdravljen svet!", 13);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
Ali zelo preprosto:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
MessageBox(NULL, "Pozdravljen svet!", "", MB_OK);
return 0;
}
[uredi] Windows Script Host
WScript.Echo "Pozdravljen svet!"
[uredi] Ruby with WxWidgets
Glej tudi TUI sekcija.
require 'wxruby'
class HelloWorldApp < Wx::App
def on_init
ourFrame = Wx::Frame.new(nil, -1, "Pozdravljen svet!").show
ourDialogBox = Wx::MessageDialog.new(ourFrame, "Pozdravljen svet!", "Information:", \
Wx::OK|Wx::ICON_INFORMATION).show_modal
end
end
HelloWorldApp.new.main_loop
[uredi] XUL
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <box align="center" pack="center" flex="1"> <description>Pozdravljen svet!</description> </box> </window>
[uredi] Document formats
[uredi] ASCII
The following sequence of characters, expressed in hexadecimal notation (with carriage return and newline characters at end of sequence):
48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21 0D 0A
The following sequence of characters, expressed as binary numbers (with cr/nl as above, and the same ordering of bytes):
00--07: 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111
08--0F: 01101111 01110010 01101100 01100100 00100001 00001101 00001010 DONTCARE*
(* The DONTCARE marker fills in for byte #0F, i.e. #15, which comes after our string.)
[uredi] LaTeX
\documentclass{article}
\begin{document}
Pozdravljen svet!
\end{document}
[uredi] XHTML 1.1
(UTF-8 kodiranje.)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sl"> <head> <title>Pozdravljen svet!</title> </head> <body> <p>Pozdravljen svet!</p> </body> </html>
[uredi] Označevalni jeziki
[uredi] HTML
(preprosto)
<html> <body> <h1>Pozdravljen svet!<p> </body> </html>
Elementa <html> in <body> nista potrebna za hitra testiranja, za <h1> je priporočljivo, da se zaključi z </h1>, tako tudi <p>, ni pa potrebno. Lahko uporabite tudi naslednje:
<pre>Pozdravljen svet!</pre>
ali pa ga preprosto napišite brez elementov.
[uredi] HTML 4.01 Strict
(polno)
(UTF-8 kodiranje.)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Pozdravljen svet!</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Pozdravljen svet!</p> </body> </html>
[uredi] XSL 1.0
(UTF-8 kodiranje.)
<?xml version="1.0" encoding="utf-8">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8"
doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"
doctype-pubilc="-//W3C//DTD XHTML 1.0 Strict//EN"/>
<xsl:template match="/">
<html>
<head>
<title>Pozdravljen svet!</title>
</head>
<body>
Pozdravljen svet!
</body>
</html>
</xsl:template>
</xsl:stylesheet>
[uredi] PostScript
/Courier findfont 24 scalefont setfont 100 100 moveto (Pozdravljen svet!) show showpage
[uredi] RTF
{\rtf1\ansi\deff0
{\fonttbl {\f0 Courier New;}}
\f0\fs20 Pozdravljen svet!
}
[uredi] TeX
\font\HW=cmr10 scaled 3000
\leftline{\HW Pozdravljen svet!}
\bye
[uredi] Zunanje povezave
- Projekt ACM "Pozdravljen svet!"
- "Kako ljudje napišejo programsko kodo za "Pozdravljen svet!", temelječ na njihovi starosti in zaposlitvi" – Izvzeto iz GNU kolekcije humorja
- Zbirka "Pozdravljen svet!" programov
- Še ena kolekcija "Pozdravljen svet!" programčkov
- Več, kot 1000 programov v različnih programskih jezikih




