
Display the string Goodbye, World! on aGUI object (alert box, plain window, text area, etc.).
/* ARM assembly AARCH64 Raspberry PI 3B *//* program disMessGraph64.s *//* link with gcc options -lX11 -L/usr/lpp/X11/lib *//*******************************************//* Constantes file *//*******************************************//* for this file see task include a file in language AArch64 assembly*/.include "../includeConstantesARM64.inc".equ ClientMessage, 33/*******************************************//* Initialized data *//*******************************************/ .dataszRetourligne: .asciz "\n"szMessErreur: .asciz "Server X11 not found.\n"szMessErrfen: .asciz "Error create X11 window.\n"szMessErrGC: .asciz "Error create Graphic Context.\n"szMessGoodBye: .asciz "Goodbye World!"szLibDW: .asciz "WM_DELETE_WINDOW" // message close window/*******************************************//* UnInitialized data *//*******************************************/ .bss.align 4qDisplay: .skip 8 // Display addressqDefScreen: .skip 8 // Default screen addressidentWin: .skip 8 // window identwmDeleteMessage: .skip 16 // ident close messagestEvent: .skip 400 // provisional sizebuffer: .skip 500 /**********************************************//* -- Code section *//**********************************************/.text .global main // program entrymain: mov x0,#0 // open server X bl XOpenDisplay cmp x0,#0 beq erreur // Ok return Display address ldr x1,qAdrqDisplay str x0,[x1] // store Display address for future use mov x28,x0 // and in register 28 // load default screen ldr x2,[x0,#264] // at location 264 ldr x1,qAdrqDefScreen str x2,[x1] //store default_screen mov x2,x0 ldr x0,[x2,#232] // screen list //screen areas ldr x5,[x0,#+88] // white pixel ldr x3,[x0,#+96] // black pixel ldr x4,[x0,#+56] // bits par pixel ldr x1,[x0,#+16] // root windows // create window x11 mov x0,x28 //display mov x2,#0 // position X mov x3,#0 // position Y mov x4,600 // weight mov x5,400 // height mov x6,0 // bordure ??? ldr x7,0 // ? ldr x8,qBlanc // background str x8,[sp,-16]! // argument fot stack bl XCreateSimpleWindow add sp,sp,16 // for stack alignement cmp x0,#0 // error ? beq erreurF ldr x1,qAdridentWin str x0,[x1] // store window ident for future use mov x27,x0 // and in register 27 // Correction of window closing error mov x0,x28 // Display address ldr x1,qAdrszLibDW // atom name address mov x2,#1 // False create atom if not exist bl XInternAtom cmp x0,#0 ble erreurF ldr x1,qAdrwmDeleteMessage // address message str x0,[x1] mov x2,x1 // address atom create mov x0,x28 // display address mov x1,x27 // window ident mov x3,#1 // number of protocoles bl XSetWMProtocols cmp x0,#0 ble erreurF // create Graphic Context mov x0,x28 // display address mov x1,x27 // window ident bl createGC // GC address -> x26 cbz x0,erreurF // Display window mov x1,x27 // ident window mov x0,x28 // Display address bl XMapWindow ldr x0,qAdrszMessGoodBye // display text bl displayText1: // events loop mov x0,x28 // Display address ldr x1,qAdrstEvent // events structure address bl XNextEvent ldr x0,qAdrstEvent // events structure address ldr w0,[x0] // type in 4 fist bytes cmp w0,#ClientMessage // message for close window bne 1b // no -> loop ldr x0,qAdrstEvent // events structure address ldr x1,[x0,56] // location message code ldr x2,qAdrwmDeleteMessage // equal ? ldr x2,[x2] cmp x1,x2 bne 1b // no loop mov x0,0 // end Ok b 100ferreurF: // error create window ldr x0,qAdrszMessErrfen bl affichageMess mov x0,1 b 100ferreur: // error no server x11 active ldr x0,qAdrszMessErreur bl affichageMess mov x0,1100: // program standard end mov x8,EXIT svc 0 qBlanc: .quad 0xF0F0F0F0qAdrqDisplay: .quad qDisplayqAdrqDefScreen: .quad qDefScreenqAdridentWin: .quad identWinqAdrstEvent: .quad stEventqAdrszMessErrfen: .quad szMessErrfenqAdrszMessErreur: .quad szMessErreurqAdrwmDeleteMessage: .quad wmDeleteMessageqAdrszLibDW: .quad szLibDWqAdrszMessGoodBye: .quad szMessGoodBye/******************************************************************//* create Graphic Context */ /******************************************************************//* x0 contains the Display address *//* x1 contains the ident Window */createGC: stp x20,lr,[sp,-16]! // save registers mov x20,x0 // save display address mov x2,#0 mov x3,#0 bl XCreateGC cbz x0,99f mov x26,x0 // save GC mov x0,x20 // display address mov x1,x26 ldr x2,qRed // code RGB color bl XSetForeground cbz x0,99f mov x0,x26 // return GC b 100f99: ldr x0,qAdrszMessErrGC bl affichageMess mov x0,0100: ldp x20,lr,[sp],16 // restaur 2 registers ret // return to address lr x30qAdrszMessErrGC: .quad szMessErrGCqRed: .quad 0xFF0000qGreen: .quad 0xFF00qBlue: .quad 0xFFqBlack: .quad 0x0/******************************************************************//* display text on screen */ /******************************************************************//* x0 contains the address of text */displayText: stp x1,lr,[sp,-16]! // save registers mov x5,x0 // text address mov x6,0 // text size1: // loop compute text size ldrb w10,[x5,x6] // load text byte cbz x10,2f // zero -> end add x6,x6,1 // increment size b 1b // and loop2: mov x0,x28 // display address mov x1,x27 // ident window mov x2,x26 // GC address mov x3,#50 // position x mov x4,#100 // position y bl XDrawString100: ldp x1,lr,[sp],16 // restaur 2 registers ret // return to address lr x30/********************************************************//* File Include fonctions *//********************************************************//* for this file see task include a file in language AArch64 assembly */.include "../includeARM64.inc"
DEFINE PTR="CARD"BYTE FUNC AtasciiToInternal(CHAR c) BYTE c2 c2=c&$7F IF c2<32 THEN RETURN (c+64) ELSEIF c2<96 THEN RETURN (c-32) FIRETURN (c)PROC CharOut(CARD x BYTE y CHAR c) BYTE i,j,v PTR addr addr=$E000+AtasciiToInternal(c)*8; FOR j=0 TO 7 DO v=Peek(addr) i=8 WHILE i>0 DO IF (v&1)=0 THEN Color=0 ELSE Color=1 FI Plot(x+i-1,y+j) v=v RSH 1 i==-1 OD addr==+1 ODRETURNPROC TextOut(CARD x BYTE y CHAR ARRAY text) BYTE i FOR i=1 TO text(0) DO CharOut(x,y,text(i)) x==+8 ODRETURNPROC Frame(CARD x BYTE y,width,height) Color=1 Plot(x,y) DrawTo(x+width-1,y) DrawTo(x+width-1,y+height-1) DrawTo(x,y+height-1) DrawTo(x,y)RETURNPROC Main() BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6 BYTE i,x,y,width=[122],height=[10] Graphics(8+16) COLOR1=$0C COLOR2=$02 FOR i=1 TO 10 DO x=Rand(320-width) y=Rand(192-height) Frame(x,y,width,height) TextOut(x+1,y+1,"Goodbye, World!") OD DO UNTIL CH#$FF OD CH=$FFRETURN
Screenshot from Atari 8-bit computer
vartextField:TextField=newTextField();stage.addChild(textField);textField.text="Goodbye, World!"
withGdk.Event;useGdk.Event;withGtk.Label;useGtk.Label;withGtk.Window;useGtk.Window;withGtk.Widget;useGtk.Widget;withGtk.Handlers;withGtk.Main;procedureWindowed_Goodbye_WorldisWindow:Gtk_Window;Label:Gtk_Label;packageHandlersis newGtk.Handlers.Callback(Gtk_Widget_Record);packageReturn_Handlersis newGtk.Handlers.Return_Callback(Gtk_Widget_Record, Boolean);functionDelete_Event(Widget:accessGtk_Widget_Record'Class)returnBooleanisbeginreturnFalse;endDelete_Event;procedureDestroy(Widget:accessGtk_Widget_Record'Class)isbeginGtk.Main.Main_Quit;endDestroy;beginGtk.Main.Init;Gtk.Window.Gtk_New(Window);Gtk_New(Label,"Goodbye, World!");Add(Window,Label);Return_Handlers.Connect(Window,"delete_event",Return_Handlers.To_Marshaller(Delete_Event'Access));Handlers.Connect(Window,"destroy",Handlers.To_Marshaller(Destroy'Access));Show_All(Label);Show(Window);Gtk.Main.Main;endWindowed_Goodbye_World;
The code below is a gentle re-write (including a bug fix) of that inthe Algol 68 Genie documentation.
Requires a version of ALGOL 68 Genie built with the GNU plotutils library libplot. See the ALGOL 68 Genie documentation.
BEGIN FILE window; open (window, "Hello!", stand draw channel); draw device (window, "X", "600x400"); draw erase (window); draw move (window, 0.25, 0.5); draw colour (window, 1, 0, 0); draw text (window, "c", "c", "Goodbye, world!"); draw show (window); close (window)END
This solution requires no code blocks as the text is entered directly into the Title properties TextBox of the Designer.
VIEW THE DESIGNER
This solution uses three blocks to assign the text to the Title bar:
Screen1.Initialize and
set Screen1.Title to "Goodbye World!"
VIEW THE BLOCKS AND ANDROID APP SCREEN
SeeSimple Windowed Application
display dialog"Goodbye, World!"buttons{"Bye"}
1 LET T$ = "GOODBYE, WORLD!" 2 LET R = 5:GX = 3:GY = 2:O = 3:XC = R + GX:YC = R * 2 + GY 3 TEXT : HOME : TEXT : HGR : HCOLOR= 7: HPLOT 0,0: CALL 62454: HCOLOR= 6 4 LET L = LEN (T$): FOR I = 1 TO L:K = ASC ( MID$ (T$,I,1)):XO = XC:YO = YC: GOSUB 5:XC = XO + 1:YC = YO: GOSUB 7: NEXT : END 5 IF K > 64 THEN K = K + LC: GOSUB 20:LC = 32: RETURN 6 LET LC = 0: ON K > = 32 GOTO 20: RETURN 7 GOSUB 20:XC = XC + R * 2 + GX: IF XC > 279 - R THEN XC = R + GX:YC = YC + GY + R * 5 8 RETURN 9 LET XC = XC - R * 2: RETURN 10 LET Y = R:D = 1 - R:X = 0 11 IF D > = 0 THEN Y = Y - 1:D = D - Y * 2 12 LET D = D + X * 2 + 3 13 IF O = 1 OR O = 3 THEN GOSUB 17 14 IF O = 2 OR O = 3 THEN GOSUB 19 15 LET X = X + 1: IF X < Y THEN 11 16 LET O = 3:E = 0: RETURN 17 HPLOT XC - X,YC + Y: HPLOT XC + X,YC + Y: HPLOT XC - Y,YC + X: IF NOT E THEN HPLOT XC + Y,YC + X 18 RETURN 19 HPLOT XC - X,YC - Y: HPLOT XC + X,YC - Y: HPLOT XC - Y,YC - X: HPLOT XC + Y,YC - X: RETURN 20 LET M = K - 31 21 ON M GOTO 32,33,34,35,36,37,38,39,40,41,42,43,44 22 LET M = M - 32 23 ON M GOTO 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87 24 LET M = M - 32 25 ON M GOTO 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,10,112,113,114,115,116,117,118,119,120,121 32 RETURN 33 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R - GY: HPLOT XC - R,YC + R: GOTO 9: REM ! 44 HPLOT XC - R,YC + R + R / 2 TO XC - R,YC + R: GOTO 9: REM , 71 LET O = 2:YC = YC - R: GOSUB 10:YC = YC + R: HPLOT XC - R,YC TO XC - R,YC - R: HPLOT XC + R / 2,YC TO XC + R,YC TO XC + R,YC + R:O = 1: GOTO 10: REM G 87 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R TO XC,YC TO XC + R,YC + R TO XC + R,YC - R * 2: RETURN : REM W 98 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 10: RETURN : REM B100 HPLOT XC + R,YC - R * 2 TO XC + R,YC + R: GOTO 10: REM D101 HPLOT XC - R,YC TO XC + R,YC:E = 1: GOTO 10: REM E108 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 9: REM L114 HPLOT XC - R,YC - R TO XC - R,YC + R:O = 2: GOTO 10: REM R121 HPLOT XC - R,YC - R TO XC,YC + R: HPLOT XC + R,YC - R TO XC - R,YC + R * 3: RETURN : REM Y
// title "Hello, World!"// first spacings [ 5 , rd ]// body /* H */ [7,pd][4,u][3,pr][3,d][7,pu]drr /* E */ [6,pd][4,pr]l[3,u][2,lp][3,u][3,pr]r /* L */ [7,pd]u[3,rp][6,u]rr /* L */ [7,pd]u[3,rp][6,u]rr /* O */ [7,pd]u[2,rp]r[6,pu][3,pl][5,r] /* , */ [5,d]prpd[3,pld][9,u][5,r] /* */ rrr /* W */ [4,pd][2,prd][2,pru][5,pu][5,d][2,prd][2,pru][5,pu]rrd /* O */ [7,pd]u[2,rp]r[6,pu][3,pl][5,r] /* R */ [7,pd][7,u][3,rp][3,pd][3,pl]rrdpr[2,dp][6,u]rr /* L */ [7,pd]u[3,rp][6,u]rr /* D */ [6,pd][3,pr][5,up]u[2,lp]p[4,r] /* ! */ r[5,pd]dp[6,u]rr// done
popup"""Goodbye, World!"
Here, you can see what thepopup box with our message looks like (on macOS).
//#include"share/atspre_define.hats"#include"share/atspre_staload.hats"//(* ****** ****** *)staload UN = $UNSAFE(* ****** ****** *)staload "{$GLIB}/SATS/glib.sats"(* ****** ****** *)staload "{$GTK}/SATS/gdk.sats"staload "{$GTK}/SATS/gtk.sats"staload "{$GLIB}/SATS/glib-object.sats"(* ****** ****** *)%{^typedef char **charpp ;%} ;abstype charpp = $extype"charpp"(* ****** ****** *)fun hello( widget: !GtkWidget1, _: gpointer) : void = print ("Goodbye, world!\n")fun on_delete_event( widget: !GtkWidget1, event: &GdkEvent, udata: gpointer) : gboolean = let val () = print ("delete event occurred\n")in GTRUE // handling of delete-event is finishedend // end of [on_delete_event]fun on_destroy (widget: !GtkWidget1, _: gpointer): void = gtk_main_quit ()// end of [on_destroy](* ****** ****** *)macdef nullp = the_null_ptr(* ****** ****** *)implementmain0 (argc, argv) ={//var argc: int = argcvar argv: charpp = $UN.castvwtp1{charpp}(argv)//val () = $extfcall (void, "gtk_init", addr@(argc), addr@(argv))//val window = gtk_window_new (GTK_WINDOW_TOPLEVEL)val () = assertloc (ptrcast(window) > 0)//val _(*id*) =g_signal_connect ( window, (gsignal)"destroy", (G_CALLBACK)on_destroy, (gpointer)nullp) (* end of [val] *)val _(*id*) =g_signal_connect ( window, (gsignal)"delete_event", (G_CALLBACK)on_delete_event, (gpointer)nullp) (* end of [val] *)//val () = gtk_container_set_border_width (window, (guint)10)val button = gtk_button_new_with_label (gstring("Goodbye, world!"))val () = assertloc (ptrcast(button) > 0)//val () = gtk_widget_show (button)val () = gtk_container_add (window, button)val () = gtk_widget_show (window)//val _(*id*) =g_signal_connect( button, (gsignal)"clicked", (G_CALLBACK)hello, (gpointer)nullp)val _(*id*) =g_signal_connect_swapped( button, (gsignal)"clicked", (G_CALLBACK)gtk_widget_destroy, window)//val () = g_object_unref (button)val () = g_object_unref (window) // ref-count becomes 1!//val ((*void*)) = gtk_main ()//} (* end of [main0] *)MsgBox,Goodbye`,World!
ToolTip,Goodbye`,World!
Gui,Add,Text,x4y4,Tobeannounced:Gui,Add,Edit,xp+90yp-3,Goodbye,World!Gui,Add,Button,xp+98yp-1,OKGui,Show,w226h22,RosettaCodeReturn
SplashTextOn,100,100,RosettaCode,Goodbye,World!
MsgBox("Goodbye, World!")
#include<GUIConstantsEx.au3>$hGUI=GUICreate("Hello World"); Create the main GUIGUICtrlCreateLabel("Goodbye, World!",-1,-1); Create a label dispalying "Goodbye, World!"GUISetState(); Make the GUI visibleWhile1; Infinite GUI loop$nMsg=GUIGetMsg(); Get any messages from the GUISwitch$nMsg; Switch for a certain eventCase$GUI_EVENT_CLOSE; When an user closes the windowsExit; ExitEndSwitchWEnd
MsgBox(0,"Goodbye","Goodbye, World!")
ToolTip("Goodbye, World!")
Awk has no GUI, but can execute system-commands.
E.g. the Windows-commandline provides a command for a messagebox,
see below atBatch_FileandUNIX_Shell.
# Usage: awk -f hi_win.awkBEGIN{system("msg * Goodbye, Msgbox !")}
This example is almost identical to theTI-83 BASIC version.
ClrHomeText(0,0,"Goodbye, world!")Pause 5000
Using Xaw backend:
OPTION GUI TRUEgui = GUIDEFINE("{ type=window name=window XtNtitle=\"Graphical\" } \ { type=labelWidgetClass name=label parent=window XtNlabel=\"Goodbye, World!\" } ")CALL GUIEVENT$(gui)Using GTK3 backend:
OPTION GUI TRUEPRAGMA GUI gtk3gui = GUIDEFINE("{ type=WINDOW name=window callback=delete-event title=\"Graphical\" } \ { type=LABEL name=label parent=window margin=5 label=\"Goodbye, World!\" } ")CALL GUIEVENT$(gui)' Demonstrate a simple Windows application using FreeBasic#includeonce"windows.bi"DeclareFunctionWinMain(ByValhInstAsHINSTANCE,_ByValhPrevAsHINSTANCE,_ByValszCmdLineasString,_ByValiCmdShowAsInteger)AsIntegerEndWinMain(GetModuleHandle(null),null,Command(),SW_NORMAL)FunctionWinMain(ByValhInstAsHINSTANCE,_ByValhPrevAsHINSTANCE,_ByValszCmdLineAsString,_ByValiCmdShowAsInteger)AsIntegerMessageBox(NULL,"Goodbye World","Goodbye World",MB_ICONINFORMATION)function=0EndFunction
' Demonstrate a simple Windows/Linux application using GTK/FreeBasic#INCLUDE"gtk/gtk.bi"gtk_init(@__FB_ARGC__,@__FB_ARGV__)VARwin=gtk_window_new(GTK_WINDOW_TOPLEVEL)gtk_window_set_title(gtk_window(win),"Goodbye, World")g_signal_connect(G_OBJECT(win),"delete-event",@gtk_main_quit,0)gtk_widget_show_all(win)gtk_main()END0
clgfont "times new roman", 20,100color orangerect 10,10, 140,30color redtext 10,10, "Goodbye, World!"
playfield:.................................................................................................XX..XXX.XXX.XX..XX..X.X.XXX.....X.X.X.X.X.X.X.X.XXX..X..XX...X..XXX.XXX.XXX.XX..XXX..X..XXX.X.......................................X.X.XXX.XX..X...XX...X..........XXX.X.X.XXX.X...X.X..X..........XXX.XXX.X.X.XXX.XX..X......................................end COLUPF = 15 COLUBK = 1mainloop drawscreen goto mainloop
From Window 7 and later, pure Batch File does not completely provide GUI. However,MSHTA.EXE provides command-line JavaScript/VBScript access.
@echo off::Output to message box [Does not work in Window 7 and later]msg *"Goodbye, World!"2>nul::Using MSHTA.EXE Hack::@mshta #"/wiki/Category:BBC_BASIC" title="Category:BBC BASIC">BBC BASIC
SYS"MessageBox",@hwnd%,"Goodbye, World!","",0
Beads specializes in graphical design and can use draw_str for html in the browser or alerts for popup boxes.
beads 1 program 'Goodbye World'calc main_initalert('Goodbye, World!')draw main_drawdraw_str('Goodbye, World!')msgbox Goodbye, World!
#include<gtk/gtk.h>intmain(intargc,char**argv){GtkWidget*window;gtk_init(&argc,&argv);window=gtk_window_new(GTK_WINDOW_TOPLEVEL);gtk_window_set_title(GTK_WINDOW(window),"Goodbye, World");g_signal_connect(G_OBJECT(window),"delete-event",gtk_main_quit,NULL);gtk_widget_show_all(window);gtk_main();return0;}
To compile with Visual C++:cl /nologo hello.c user32.lib, or with Open Watcom:wcl386 /q hello.c user32.lib.
#include<windows.h>intmain(void){MessageBox(NULL,TEXT("Goodbye, World!"),TEXT("Rosetta Code"),MB_OK|MB_ICONINFORMATION);return0;}
The following program shows a message box in OS/2 PM. Tested in ArcaOS.
To compile with Open Watcom:
wcc386 hello.cwlink system os2v2_pm name hello file hello.obj
#include<os2.h>intmain(void){HABhab;HMQhmq;hab=WinInitialize(0);hmq=WinCreateMsgQueue(hab,0);WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,"Hello, Presentation Manager!","My Program",0L,0L);WinDestroyMsgQueue(hmq);WinTerminate(hab);return0;}
Using the graphics library included with Turbo C. The BGI driver and the font must be in the same directory as the program (EGAVGA.BGI andSANS.CHR). Compile withtcc hellobgi.c graphics.lib.
#include<conio.h>#include<graphics.h>intmain(void){intDriver=DETECT,Mode;intMaxX,MaxY,X,Y;charMessage[]="Hello, World!";initgraph(&Driver,&Mode,"");MaxX=getmaxx();MaxY=getmaxy();settextstyle(SANS_SERIF_FONT,HORIZ_DIR,7);X=(MaxX-textwidth(Message))>>1;Y=(MaxY-textheight(Message))>>1;outtextxy(X,Y,Message);getch();closegraph();return0;}
usingSystem;usingSystem.Windows.Forms;classProgram{staticvoidMain(string[]args){Application.EnableVisualStyles();//Optional.MessageBox.Show("Goodbye, World!");}}
usingGtk;usingGtkSharp;publicclassGoodbyeWorld{publicstaticvoidMain(string[]args){Gtk.Windowwindow=newGtk.Window();window.Title="Goodbye, World";window.DeleteEvent+=delegate{Application.Quit();};window.ShowAll();Application.Run();}}
#include<gtkmm.h>intmain(intargc,char*argv[]){Gtk::Mainapp(argc,argv);Gtk::MessageDialogmsg("Goodbye, World!");msg.run();}
All Win32 APIs work in C++ the same way as they do in C. See the C example.
Where pWnd is a pointer to a CWnd object corresponding to a valid window in the application.
#include"afx.h"voidShowGoodbyeWorld(CWnd*pWnd){pWnd->SetWindowText(_T("Goodbye, World!"));}
#include<FL/Fl.H>#include<FL/Fl_Window.H>#include<FL/Fl_Box.H>intmain(intargc,char**argv){Fl_Window*window=newFl_Window(300,180);Fl_Box*box=newFl_Box(20,40,260,100,"Goodbye, World!");box->box(FL_UP_BOX);box->labelsize(36);box->labelfont(FL_BOLD+FL_ITALIC);box->labeltype(FL_SHADOW_LABEL);window->end();window->show(argc,argv);returnFl::run();}
usingnamespaceSystem::Windows::Forms;intmain(array<System::String^>^args){MessageBox::Show("Goodbye, World!","Rosetta Code");return0;}
To configure the "Graphical screen"
ViewWindow 1,127,1,1,63,1AxesOffCoordOffGridOffLabelOff
ViewWindow parameters depend on the calculator resolution (These are the most common).
To print text on the "Graphical screen" of the calculator:
Text 1,1,"Goodbye, World!"ClrGraph
importStdEnv,StdIOStart::*World->*WorldStartworld=startIONDIVoid(sndoopenDialogundefhello)[]worldwherehello=Dialog""(TextControl"Goodbye, World!"[])[WindowClose(noLScloseProcess)]
(nsexperimentation.core(:import(javax.swingJOptionPaneJFrameJTextAreaJButton)(java.awtFlowLayout)))(JOptionPane/showMessageDialognil"Goodbye, World!")(let[button(JButton."Goodbye, World!")window(JFrame."Goodbye, World!")text(JTextArea."Goodbye, World!")](dotowindow(.setLayout(FlowLayout.))(.addbutton)(.addtext)(.pack)(.setDefaultCloseOperation(JFrame/EXIT_ON_CLOSE))(.setVisibletrue)))
(nsexample(:require[cljfx.api:asfx]))(fx/on-fx-thread(fx/create-component{:fx/type:stage:showingtrue:title"Cljfx example":width300:height100:scene{:fx/type:scene:root{:fx/type:v-box:alignment:center:children[{:fx/type:label:text"Goodbye, world"}]}}}))
The following are in the Managed COBOL dialect.
CLASS-IDProgramClass.METHOD-IDMainSTATIC.PROCEDUREDIVISION.INVOKETYPEApplication::EnableVisualStyles()*> OptionalINVOKETYPEMessageBox::Show("Goodbye, World!")ENDMETHOD.ENDCLASS.
gui.xaml.cbl:
CLASS-IDGoodbyeWorldWPF.WindowISPARTIALINHERITSTYPESystem.Windows.Window.METHOD-IDNEW.PROCEDUREDIVISION.INVOKEself::InitializeComponent()ENDMETHOD.ENDCLASS.
gui.xaml:
<Window x:Class="COBOL_WPF.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Hello world/Graphical"> <TextBox>Goodbye, World!</TextBox></Window>
*> *> cobweb-gui-hello, using gtk-label *> Tectonics: *> cobc -w -xj cobweb-gui-hello.cob cobweb-gtk.cob \ *> `pkg-config --libs gtk+-3.0` *>identificationdivision.program-id.cobweb-gui-hello.environmentdivision.configurationsection.repository.functionnew-windowfunctionnew-boxfunctionnew-labelfunctiongtk-gofunctionallintrinsic.datadivision.working-storagesection.01TOPLEVELusagebinary-longvalue0.01HORIZONTALusagebinary-longvalue0.01VERTICALusagebinary-longvalue1.01width-hintusagebinary-longvalue160.01height-hintusagebinary-longvalue16.01spacingusagebinary-longvalue8.01homogeneoususagebinary-longvalue0.01extraneoususagebinary-long.01gtk-window-data.05gtk-windowusagepointer.01gtk-container-data.05gtk-containerusagepointer.01gtk-box-data.05gtk-boxusagepointer.01gtk-label-data.05gtk-labelusagepointer.proceduredivision.cobweb-hello-main. *> Main window and top level containermovenew-window("Hello",TOPLEVEL,width-hint,height-hint)togtk-window-datamovenew-box(gtk-window,VERTICAL,spacing,homogeneous)togtk-container-data *> Box, across, with simple labelmovenew-box(gtk-container,HORIZONTAL,spacing,homogeneous)togtk-box-datamovenew-label(gtk-box,"Goodbye, World!")togtk-label-data *> GTK+ event loop now takes overmovegtk-go(gtk-window)toextraneousgoback.endprogramcobweb-gui-hello.
The program gets the lines and columns of the screen and positions the text in the middle. Program waits for a return key.
program-id.ghello. datadivision. working-storagesection. 01varpic x(1). 01lynzpic 9(3). 01colzpic 9(3). 01msgpic x(15)value"Goodbye, world!". proceduredivision. acceptlynzfromlinesend-acceptdividelynzby2givinglynz. acceptcolzfromcolumnsend-acceptdividecolzby2givingcolz. subtract7fromcolzgivingcolz. displaymsgatlinenumberlynzcolumnnumbercolz end-display acceptvarend-acceptstoprun.
Requires
GUI library.
@args -pkg:gtk-sharp-2.0use Gtkclass MainProgram def main Application.init dialog = MessageDialog(nil, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Ok, "Goodbye, World!") dialog.run dialog.destroy
alert"Goodbye, World!"
There are no text drawing routines in BASIC that apply to the high resolution bitmap mode on the Commodore 64. Therefore, it is necessary to either draw letterforms from designs stored in RAM, or copy the font contained in ROM. It should be noted that using BASIC to handle high resolution graphics is a slow process, and the same tasks are much more efficiently accomplished in assembly language/machine code.
This example will iterate through the string and copy the appropriate bitmap information from the Character ROM. In line 425 a conversion must take place since strings are stored in memory as bytes of ASCII (PETSCII) codes, however, the Character ROM is stored in order of the screen codes as found inAppendix B of the Commodore 64 Programmer's Reference Guide... And even then the conversion given will work only for a limited set of the Character ROM. This could be remedied if the Character ROM (or some other font definition) was copied to RAM and indexed in ASCII/PETSCII order.
The POKE statements encapsulating the text drawing routine (lines 410-415 and 450-455) are necessary to make the Character ROM visible to BASIC without crashing the operating system. As such, keyboard scanning must be suspended during this time, preventing the routine from any user interruption until it is finished.
1 rem hello world on graphics screen2 rem commodore 64 version10 print chr$(147): print " press c to clear bitmap area,"15 print " any other key to continue"20 get k$:if k$="" then 2025 if k$<>"c" then goto 4030 poke 53280,0:print chr$(147):print " clearing bitmap area... please wait..."35 base=8192:for i=base to base+7999:poke i,0:next40 print chr$(147);45 poke 53272,peek(53272) or 8:rem set bitmap memory at 8192 ($2000)50 poke 53265,peek(53265) or 32:rem enter bitmap mode55 rem write text to graphics at tx,ty60 t$="goodbye, world!":tx=10:ty=1065 gosub 40070 rem draw sine wave - prove we are in hi-res mode75 for x=0 to 319:y=int(50*sin(x/10))+100:gosub 500:next80 rem wait for keypress85 get k$:if k$="" then 8590 rem back to text mode, restore colors, end program95 poke 53265,peek(53265) and 223:poke 53272,peek(53272) and 247100 poke 53280,14:poke 53281,6:poke 646,14200 end400 rem write text to graphics routine405 tx=tx+(40*ty):m=base+(tx*8)410 poke 56334,peek(56334) and 254 : rem turn off keyscan415 poke 1,peek(1) and 251 : rem switch in chargen rom420 for i=1 to len(t$)425 l=asc(mid$(t$,i,1))-64:if l<0 then l=l+64430 for b=0 to 7435 poke m,peek(53248+(l*8)+b)440 m=m+1445 next b, i450 poke 1,peek(1) or 4 : rem switch in io455 poke 56334,peek(56334) or 1 : rem restart keyscan460 return500 rem plot a single pixel at x,y510 mem=base+int(y/8)*320+int(x/8)*8+(y and 7)520 px=7-(x and 7)530 poke mem,peek(mem) or 2^px540 return
This can be done using the extension packageltk that provides an interface to theTk library.
(use-package:ltk)(defunshow-message(text)"Show message in a label on a Tk window"(with-ltk()(let*((label(make-instance'label:texttext))(button(make-instance'button:text"Done":command(lambda()(ltk::break-mainloop)(ltk::update)))))(packlabel:side:top:expandt:fill:both)(packbutton:side:right)(mainloop))))(show-message"Goodbye World")
This can also be done using theCLIM 2.0 specification. The following code runs on both SBCL and the LispWorksIDE:
(in-package:clim-user)(defclasshello-world-pane(clim-stream-pane)())(define-application-framehello-world()((greeting:initform"Goodbye World":accessorgreeting))(:pane(make-pane'hello-world-pane)));;; Behaviour defined by the Handle Repaint Protocol(defmethodhandle-repaint((panehello-world-pane)region)(let((w(bounding-rectangle-widthpane))(h(bounding-rectangle-heightpane)));; Blank the pane out(draw-rectangle*pane00wh:filledt:ink(pane-backgroundpane));; Draw greeting in center of pane(draw-text*pane(greeting*application-frame*)(floorw2)(floorh2):align-x:center:align-y:center)))(run-frame-top-level(make-application-frame'hello-world:width200:height200))
DEF Win:WINDOWDEF Close:CHARDEF ScreenSizeX,ScreenSizeY:INTGETSCREENSIZE(ScreenSizeX,ScreenSizeY)WINDOW Win,0,0,ScreenSizeX,ScreenSizeY,0,0,"Goodbye program",MainHandlerPRINT Win,"Goodbye, World!"'Prints in the upper left corner of the window (position 0,0).WAITUNTIL Close=1CLOSEWINDOW WinEND SUB MainHandler IF @CLASS=@IDCLOSEWINDOW THEN Close=1 RETURN
require"crsfml"window=SF::RenderWindow.new(SF::VideoMode.new(800,600),"Hello world/Graphical")# A font file(s) MUST be in the directory of the Crystal file itself.# CrSFML does NOT load font files from the filesystem root!font=SF::Font.from_file("DejaVuSerif-Bold.ttf")text=SF::Text.newtext.font=fonttext.string="Goodbye, world!"text.character_size=24text.color=SF::Color::Blackwhilewindow.open?whileevent=window.poll_eventifevent.is_a?SF::Event::Closedwindow.closeendendwindow.clear(SF::Color::White)window.draw(text)window.displayend
importgtk.MainWindow,gtk.Label,gtk.Main;classGoodbyeWorld:MainWindow{this(){super("GtkD");add(newLabel("Goodbye World"));showAll();}}voidmain(string[]args){Main.init(args);newGoodbyeWorld();Main.run();}
Because Flutter works on the Web in addition to Mobiles and Desktop, you can view these examples on Dartpad! -https://dartpad.github.io
Simplest (and ugliest) solution
import'package:flutter/material.dart';main()=>runApp(MaterialApp(home:Text("Goodbye, World!")));
A still bare bones but much better looking example that displays a white screen with the text centered
import'package:flutter/material.dart';voidmain(){runApp(MaterialApp(debugShowCheckedModeBanner:false,home:Scaffold(body:Center(child:Text("Goodbye, World!")))));}
Html dom manipulation, Dart has first class support for compilation to JavaScript. This simply sets the innerHtml of the body to 'Goodbye, World!'
import'dart:html';main()=>document.body.innerHtml='<p>Goodbye, World!</p>';
import'dart:html';main()=>window.alert("Goodbye, World!");
programHelloWorldGraphical;usesDialogs;beginShowMessage('Goodbye, World!');end.
To differentiate only a GUI message use thedisplay_ verb.
display_me()_msg(Goodbye, World!);
However, using the_msg (short for 'message') action will send a string message to the callee who may decide to display the string graphically...
me_msg(Goodbye, World!);
(This works entered into the interactive shell):
notify-user("Goodbye, World!",frame:make(<frame>));
This is a complete application. If it were part of a larger application, the portions related tointerp would be removed.
def <widget> := <swt:widgets.*>def SWT := <swt:makeSWT>def frame := <widget:makeShell>(currentDisplay) frame.setText("Rosetta Code") frame.setBounds(30, 30, 230, 60) frame.addDisposeListener(def _ { to widgetDisposed(event) { interp.continueAtTop() }})def label := <widget:makeLabel>(frame, SWT.getLEFT()) label.setText("Goodbye, World!") swtGrid`$frame: $label`frame.open()interp.blockAtTop()gcolor 700gtext 10 60 "Goodbye, World!"
MessageBox:
import"ecere"MessageBoxgoodBye{contents="Goodbye, World!"};
Label:
import"ecere"Labellabel{text="Goodbye, World!",hasClose=true,opacity=1,size={320,200}};
Titled Form + Surface Output:
import"ecere"classGoodByeForm:Window{text="Goodbye, World!";size={320,200};hasClose=true;voidOnRedraw(Surfacesurface){surface.WriteTextf(10,10,"Goodbye, World!");}}GoodByeFormform{};
(alert"Goodbye, World!")
Allows entry of any name into a text field (using "World" as the default entry). Then, when the "Say Goodbye" button is pressed, sets a text label to the value "Goodbye, <name>!".
import org.eclipse.edt.rui.widgets.*;import dojo.widgets.*;handler HelloWorld type RUIhandler{initialUI =[ui]} ui Box {columns=1, children=[nameField, helloLabel, goButton]}; nameField DojoTextField {placeHolder = "What's your name?", text = "World"}; helloLabel TextLabel {}; goButton DojoButton {text = "Say Goodbye", onClick ::= onClick_goButton}; function onClick_goButton(e Event in) helloLabel.text = "Goodbye, " + nameField.text + "!"; endendELENA 6.x :
import forms; public class MainWindow : SDIDialog{ Label goodByeWorldLabel; Button closeButton; constructor new() <= super new() { self.Caption := "ELENA"; goodByeWorldLabel := Label.new(); closeButton := Button.new(); self .appendControl(goodByeWorldLabel) .appendControl(closeButton); self.setRegion(250, 200, 200, 110); goodByeWorldLabel.Caption := "Goodbye, World!"; goodByeWorldLabel.setRegion(40, 10, 150, 30); closeButton.Caption := "Close"; closeButton.setRegion(20, 40, 150, 30); closeButton.onClick := (args){ forward Program.stop() }; }}The form markup:
<Form :Name="MainWindow" :Height="110" :Width="200" Caption="ELENA 6.0"> <Label :Name="labCaption" :X="40" :Y="10" :Width="150" :Height="30" Caption="ELENA"> </Label> <Button :Name="btnExit" :X="20" :Y="40" :Width="150" :Height="30" Caption="Close" :onClick="&onExit"> </Button></Form>
import xforms;import forms;public class MainWindow : XForm, using(MainWindow){ constructor new() <= super new() { } private onExit(sender) { forward Program.stop() }}(message-box"Goodbye, World!")
include msgbox.einteger responseresponse = message_box("Goodbye, World!","Bye",MB_OK)Just display the text in a message box.
#lightopenSystemopenSystem.Windows.Forms[<EntryPoint>]letmain_=MessageBox.Show("Hello World!")|>ignore0
To be pasted in the listener :
USING: ui ui.gadgets.labels ; [ "Goodbye World" <label> "Rosetta Window" open-window ] with-ui
using fwtclass Hello{ public static Void main () { Dialog.openInfo (null, "Goodbye world") }}(fnlove.load[](love.window.setMode300300{"resizable"false})(love.window.setTitle"Hello world/Graphical in Fennel!"))(let[str"Goodbye, World!"](fnlove.draw[](love.graphics.printstr95150)))
To run this, you need to have LÖVE installed in your machine, and then run this commandfennel --compile love_test.fnl > main.lua; love .. Since LÖVE has no compatibility with Fennel, we need to AOT-compile the file to a Lua file calledmain.lua, so then LÖVE can execute the program.
HWNDz"Goodbye,World!"z"(title)"MB_OKMessageBox
Alternative:
s"Goodbye, World!"MsgBox
Here are solutions forMicrosoft Windows, using theMessageBox API function. Both programs use modules provided by the compiler vendor.
programhellousewindowsinteger::resres=MessageBoxA(0,LOC("Hello, World"),LOC("Window Title"),MB_OK)end program
Compile withaf90 hello.f90 user32.lib or for a 64-bit executableaf90 -i8 -m64 hello.f90 user32.lib.
programhellouseuser32integer::resres=MessageBox(0,"Hello, World","Window Title",MB_OK)end program
Compile withifort hello.f90.
Usinggtk-fortran library
modulehandlers_museiso_c_bindingusegtkimplicit none contains subroutinedestroy(widget,gdata)bind(c)type(c_ptr),value::widget,gdatacallgtk_main_quit()end subroutinedestroyend modulehandlers_mprogramtestuseiso_c_bindingusegtkusehandlers_mimplicit none type(c_ptr)::windowtype(c_ptr)::boxtype(c_ptr)::buttoncallgtk_init()window=gtk_window_new(GTK_WINDOW_TOPLEVEL)callgtk_window_set_default_size(window,500,20)callgtk_window_set_title(window,"gtk-fortran"//c_null_char)callg_signal_connect(window,"destroy"//c_null_char,c_funloc(destroy))box=gtk_hbox_new(TRUE,10_c_int);callgtk_container_add(window,box)button=gtk_button_new_with_label("Goodbye, World!"//c_null_char)callgtk_box_pack_start(box,button,FALSE,FALSE,0_c_int)callg_signal_connect(button,"clicked"//c_null_char,c_funloc(destroy))callgtk_widget_show(button)callgtk_widget_show(box)callgtk_widget_show(window)callgtk_main()end programtest
Compile withgfortran gtk2_mini.f90 -o gtk2_mini.x `pkg-config --cflags --libs gtk-2-fortran`
Graphics Mode
screen1'Mode 320x200locate12,15?"Goodbye, World!"sleep
Windows API
#INCLUDE"windows.bi"MessageBox(0,"Goodbye, World!","Message",0)
package HelloWorldGraphical whereimport Java.Swingmain _ = do frame <- JFrame.new "Goodbye, world!" frame.setDefaultCloseOperation(JFrame.dispose_on_close) label <- JLabel.new "Goodbye, world!" cp <- frame.getContentPane cp.add label frame.pack frame.setVisible true
This brings up an infinitely-rescalable graphic window containing "Goodbye, World" drawn graphically.
All Frink graphics can be written to arbitrary coordinates; Frink will automatically scale and center any drawn graphics to be visible in the window (greatly simplifying programming,) so the exact coordinates used below are rather arbitrary. (This means that if you wrote "Hello World" instead of "Goodbye, World", you could just change that string and everything would still center perfectly.)
The graphics are infinitely-scalable and can be rendered at full quality to any resolution. This program "shows off" by rotating the text by 10 degrees, and also rendering it to a printer (which can include tiling across multiple pages) and rendering to a graphics file. (Frink can automatically render the same graphics object to many image formats, including PNG, JPG, SVG, HTML5 canvas, animated GIF, bitmapped image in memory, and more.)
g = new graphicsg.font["SansSerif", 10]g.text["Goodbye, World!", 0, 0, 10 degrees]g.show[]g.print[] // Optional: render to printerg.write["GoodbyeWorld.png", 400, 300] // Optional: write to graphics file
native javax.swing.{SwingUtilities, JPanel, JLabel, JFrame}native java.awt.Fontdef createAndShowGUI( msg ) = f = JFrame() f.setTitle( msg ) f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ) p = JPanel() l = JLabel( msg ) l.setFont( Font.decode(Font.SERIF + ' 150') ) p.add( l ) f.add( p ) f.pack() f.setResizable( false ) f.setVisible( true )SwingUtilities.invokeLater( createAndShowGUI.runnable('Goodbye, World!') )Easy peasy.
alert 1, NSWarningAlertStyle, @"Goodbye, World!", @"It's been real.", @"See ya!", YESHandleEvents
Message.Info("Goodbye, World!")' Display a simple message box
[indent=4]/* Genie GTK+ hello valac --pkg gtk+-3.0 hello-gtk.gs ./hello-gtk*/uses Gtkinit Gtk.init (ref args) var window = new Window (WindowType.TOPLEVEL) var label = new Label("Goodbye, World!") window.add(label) window.set_default_size(160, 100) window.show_all() window.destroy.connect(Gtk.main_quit) Gtk.main()The text is rendered using Braille text characters.
debug="⡧⢼⣟⣋⣇⣀⣇⣀⣏⣹⠀⠀⣇⣼⣏⣹⡯⡽⣇⣀⣏⡱⢘⠀"
draw_text(0,0,"Goodbye World!");
packagemainimport"github.com/mattn/go-gtk/gtk"funcmain(){gtk.Init(nil)win:=gtk.NewWindow(gtk.WINDOW_TOPLEVEL)win.SetTitle("Goodbye, World!")win.SetSizeRequest(300,200)win.Connect("destroy",gtk.MainQuit)button:=gtk.NewButtonWithLabel("Goodbye, World!")win.Add(button)button.Connect("clicked",gtk.MainQuit)win.ShowAll()gtk.Main()}
importgroovy.swing.SwingBuilderimportjavax.swing.JFramenewSwingBuilder().edt{optionPane().showMessageDialog(null,"Goodbye, World!")frame(title:'Goodbye, World!',defaultCloseOperation:JFrame.EXIT_ON_CLOSE,pack:true,show:true){flowLayout()button(text:'Goodbye, World!')textArea(text:'Goodbye, World!')}}
Here we display the message on the system notepad:
Start,Programs,Accessories,Notepad,Type:Goodbye[comma][space]World[pling]
PROCEDURE Main()RETURN wapi_MessageBox(,"Goodbye, World!","")
Using
fromHackageDB
importGraphics.UI.GtkimportControl.MonadmessDialog=doinitGUIdialog<-messageDialogNewNothing[]MessageInfoButtonsOk"Goodbye, World!"rs<-dialogRundialogwhen(rs==ResponseOk||rs==ResponseDeleteEvent)$widgetDestroydialogdialog`onDestroy`mainQuitmainGUI
Run in GHCi interpreter:
*Main>messDialog
WRITE(Messagebox='!') 'Goodbye, World!'
PopUpOk("Goodbye, World!");linkgraphicsproceduremain()WOpen("size=100,20")|stop("No window")WWrites("Goodbye, World!")WDone()end
importgui$include"guih.icn"classWindowApp:Dialog()# -- automatically called when the dialog is createdmethodcomponent_setup()# add 'hello world' labellabel:=Label("label=Hello world","pos=0,0")add(label)# make sure we respond to close eventconnect(self,"dispose",CLOSE_BUTTON_EVENT)endend# create and show the windowproceduremain()w:=WindowApp()w.show_modal()end
With an alert box:
MSGBOX("Goodbye, World!");By drawing directly to the screen:
RECT();TEXTOUT_P("Goodbye, World!", GROBW_P(G0)/4, GROBH_P(G0)/4, 7);WAIT(-1);graphics {display("Goodbye, World!")}40×40 isn't great resolution, but it's enough!
10REM FONT DERIVED FROM 04B-09 BY YUJI OSHIMOTO20GR30COLOR=1240REM G50HLIN0,5AT0:HLIN0,5AT160VLIN2,9AT0:VLIN2,9AT170HLIN2,5AT9:HLIN2,5AT880VLIN4,7AT5:VLIN4,7AT490VLIN4,5AT3100REM O110HLIN7,12AT2:HLIN7,12AT3120HLIN7,12AT8:HLIN7,12AT9130VLIN4,7AT7:VLIN4,7AT8140VLIN4,7AT11:VLIN4,7AT12150REM O160HLIN14,19AT2:HLIN14,19AT3170HLIN14,19AT8:HLIN14,19AT9180VLIN4,7AT14:VLIN4,7AT15190VLIN4,7AT18:VLIN4,7AT19200REM D210HLIN21,24AT2:HLIN21,24AT3220HLIN21,26AT8:HLIN21,26AT9230VLIN4,7AT21:VLIN4,7AT22240VLIN0,7AT25:VLIN0,7AT26250REM -260HLIN28,33AT4:HLIN28,33AT5270REM B280VLIN11,20AT0:VLIN11,20AT1290HLIN2,5AT20:HLIN2,5AT19300VLIN15,18AT5:VLIN15,18AT4310HLIN2,5AT14:HLIN2,5AT13320REM Y330VLIN13,20AT7:VLIN13,20AT8340VLIN19,20AT9:VLIN19,20AT10350VLIN13,24AT11:VLIN13,24AT12360VLIN23,24AT10:VLIN23,24AT9370REM E380VLIN13,20AT14:VLIN13,20AT15390HLIN16,19AT13:HLIN16,19AT14400HLIN18,19AT15:HLIN18,19AT16410HLIN16,17AT17:HLIN16,17AT18420HLIN16,19AT19:HLIN16,19AT20430REM ,440VLIN17,22AT21:VLIN17,22AT22450REM W460VLIN24,33AT0:VLIN24,33AT1:VLIN24,33AT3470VLIN24,33AT4:VLIN24,33AT6:VLIN24,33AT7480HLIN0,7AT33:HLIN0,7AT32490REM O500HLIN9,14AT26:HLIN9,14AT27510HLIN9,14AT32:HLIN9,14AT33520VLIN28,31AT9:VLIN28,31AT10530VLIN28,31AT13:VLIN28,31AT14540REM R550HLIN16,21AT26:HLIN16,21AT27560VLIN28,33AT16:VLIN28,33AT17570REM L580VLIN24,33AT23:VLIN24,33AT24590REM D600HLIN26,29AT26:HLIN26,29AT27610HLIN26,29AT32:HLIN26,29AT33620VLIN28,33AT26:VLIN28,33AT27630VLIN24,33AT30:VLIN24,33AT31640REM !650VLIN24,29AT33:VLIN24,29AT34660VLIN32,33AT33:VLIN32,33AT34670END
import(:javax:swing,:JOptionPane,:JFrame,:JTextArea,:JButton)importjava:awt:FlowLayoutJOptionPaneshowMessageDialog(nil,"Goodbye, World!")button=JButtonnew("Goodbye, World!")text=JTextAreanew("Goodbye, World!")window=JFramenew("Goodbye, World!")do(layout=FlowLayoutnewadd(button)add(text)packsetDefaultCloseOperation(JFramefield:EXIT_ON_CLOSE)visible=true)
DEF Win:WINDOWDEF Close:CHARDEF ScreenSizeX,ScreenSizeY:UINTGETSCREENSIZE(ScreenSizeX,ScreenSizeY)OPENWINDOW Win,0,0,ScreenSizeX,ScreenSizeY,NULL,NULL,"Goodbye program",&MainHandlerPRINT Win,"Goodbye, World!"'Prints in upper left corner of the window (position 0,0).WAITUNTIL Close=1CLOSEWINDOW WinENDSUB MainHandler IF @MESSAGE=@IDCLOSEWINDOW THEN Close=1RETURNENDSUB
wdinfo'Goodbye, World!'
importjavax.swing.*;importjava.awt.*;publicclassOutputSwing{publicstaticvoidmain(String[]args){SwingUtilities.invokeLater(newRunnable(){publicvoidrun(){JOptionPane.showMessageDialog(null,"Goodbye, World!");// in alert boxJFrameframe=newJFrame("Goodbye, World!");// on title barJTextAreatext=newJTextArea("Goodbye, World!");// in editable areaJButtonbutton=newJButton("Goodbye, World!");// on buttonframe.setLayout(newFlowLayout());frame.add(button);frame.add(text);frame.pack();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);}});}}
Using Java 8 lambdas syntax:
importjavax.swing.*;importjava.awt.*;publicclassHelloWorld{publicstaticvoidmain(String[]args){SwingUtilities.invokeLater(()->{JOptionPane.showMessageDialog(null,"Goodbye, world!");JFrameframe=newJFrame("Goodbye, world!");JTextAreatext=newJTextArea("Goodbye, world!");JButtonbutton=newJButton("Goodbye, world!");frame.setLayout(newFlowLayout());frame.add(button);frame.add(text);frame.pack();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);});}}
alert("Goodbye, World!");
In the following, which generates SVG in a way that can be readily viewed using a web browser, the "Goodbye, World!" text is shaded using a linear gradient.
The approach used here to generate SVG is based on these principles:
Part 1: Generic SVG-related functions
# Convert a JSON object to a string suitable for use as a CSS style value# e.g: "font-size: 40px; text-align: center;" (without the quotation marks)def to_s: reduce to_entries[] as $pair (""; . + "\($pair.key): \($pair.value); ");# Defaults: 100%, 100%def svg(width; height): "<svg width='\(width // "100%")' height='\(height // "100%")' xmlns='http://www.w3.org/2000/svg'>";# Defaults:# id: "linearGradient"# color1: rgb(0,0,0)# color2: rgb(255,255,255)def linearGradient(id; color1; color2): "<defs> <linearGradient id='\(id//"linearGradient")' x1='0%' y1='0%' x2='100%' y2='0%'> <stop offset='0%' style='stop-color:\(color1//"rgb(0,0,0)");stop-opacity:1' /> <stop offset='100%' style='stop-color:\(color2//"rgb(255,255,255)");stop-opacity:1' /> </linearGradient> </defs>";# input: the text string# "style" should be a JSON object (see for example the default ($dstyle));# the style actually used is (default + style), i.e. whatever is specified in "style" wins.# Defaults:# x: 0# y: 0def text(x; y; style): . as $in | {"font-size": "40px", "text-align": "center", "text-anchor": "left", "fill": "black"} as $dstyle | (($dstyle + style) | to_s) as $style | "<text x='\(x//0)' y='\(y//0)' style='\($style)'> \(.)", "</text>";Part 2: "Goodbye, World!"
def task: svg(null;null), # use the defaults linearGradient("gradient"; "rgb(255,255,0)"; "rgb(255,0,0)"), # define "gradient" ("Goodbye, World!" | text(10; 50; {"fill": "url(#gradient)"})), # notice how the default for "fill" is overridden "</svg>";taskjq -n -r -f Hello_word_Graphical.jq > Hello_word_Graphical.svg
Text 25,10,"Goodbye, World!"
Using JSI CData processing, C, and linking to libAgar.
prompt$ jsishJsish interactive: see 'help [cmd]'. \ cancels > input. ctrl-c aborts running script.# require('JsiAgarGUI')1# JsiAgarGUI.alert("Goodbye, World!");#Window pops up with message and Ok button.
That is based on JSI CData, a blend of typed Javascript and C, interwoven via a preprocessor.
extensionJsiAgarGUI={// libAgar GUI from Jsi/* Alert popup, via libAgar and Jsish CData tectonics: jsish -c JsiAgar.jsc gcc `jsish -c -cflags true JsiAgar.so` `agar-config --cflags --libs` jsish -e 'require("JsiAgar"); JsiAgar.alert("Goodbye, World!");' */#include<agar/core.h>#include<agar/gui.h>/* Terminate on close */voidwindDown(AG_Event*event){AG_Terminate(0);}functionalert(msg:string):void{// Display a JsiAgar windowed message/* Native C code block (in a JSI function wrapper) */AG_Window*win;AG_Box*box;Jsi_RCrc=JSI_OK;if(AG_InitCore(NULL,0)==-1||AG_InitGraphics(0)==-1)return(JSI_ERROR);AG_BindStdGlobalKeys();win=AG_WindowNew(0);box=AG_BoxNew(win,AG_BOX_VERT,0);AG_LabelNewS(box,AG_LABEL_HFILL,msg);AG_ButtonNewFn(box,AG_BUTTON_HFILL,"Ok",AGWINDETACH(win),"%p",win);AG_SetEvent(win,"window-detached",windDown,NULL);AG_WindowShow(win);AG_EventLoop();AG_DestroyGraphics();AG_Destroy();returnrc;}};
Build rules arejsish -c preprocessor, queryjsish for C compile time flags, compile the C, load the module into jsish viarequire.
prompt$ make -B -f Makefile.jsc hellojsish -c JsiAgarGUI.jscgcc `jsish -c -cflags true JsiAgarGUI.so` `agar-config --cflags --libs`jsish -e 'require("JsiAgarGUI"); JsiAgarGUI.alert(" Goodbye, World! ");'And a window pops up with the message and an Ok button.
First commandjsish -c runs a JSI to C preprocessor, generating a.h C source file.
For the second step, gcc is called with the output of ajsish -c -cflags true query, libagar runtime is linked in with more substitution for Agar compiler commands. The query output will be something like (this is site local, details will change per machine setup):
prompt$ jsish -c -cflags true JsiAgarGUI.so-g -Og -O0 -Wall -fPIC -DJSI__SQLITE=1 -DJSI__READLINE=1 -fno-diagnostics-show-caret -Wc++-compat -Wwrite-strings -DCDATA_MAIN=1 -x c -rdynamic -I/home/btiffin/forge/jsi/jsish/src -DJSI__WEBSOCKET=1 -I/home/btiffin/forge/jsi/jsish/websocket/src/lib -I/home/btiffin/forge/jsi/jsish/websocket/src/build -I/home/btiffin/forge/jsi/jsish/websocket/unix -I/home/btiffin/forge/jsi/jsish/websocket/build/unix -o JsiAgarGUI.so JsiAgarGUI.h -lm -shared -DCDATA_SHARED=1 -L /home/btiffin/forge/jsi/jsish/websocket/build/unix/ -lwebsockets -I/home/btiffin/forge/jsi/jsish/sqlite/src -L /home/btiffin/forge/jsi/jsish/sqlite/build/unix/ -lsqlite3 -lm -ldl -lpthreadprompt$ agar-config --cflags --libs-I/usr/local/include/agar -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libpng16 -L/usr/local/lib -lag_gui -lag_core -lSDL -lpthread -lfreetype -lfontconfig -lfreetype -L/usr/local/lib -lGL -lX11 -lXinerama -lm -L/usr/lib -ljpeg -L/usr/lib64 -lpng16 -ldl
A JSI ready module is created, the C build rules managed by CData along with the.jsc JSI to C to JSI code generation.
As listed at the top, this GUI can be called up while in the interactive console.
usingTkwindow=Toplevel("Hello World",200,100,false)pack_stop_propagate(window)fr=Frame(window)pack(fr,expand=true,fill="both")txt=Label(fr,"Hello World")pack(txt,expand=true)set_visible(window,true)# sleep(7)
print "Goodbye, World!"'Prints in the upper left corner of the default text window: mainwin, a window with scroll bars.
Popping a dialog-box.
function main() { Konsol:Message("Goodbye, World!", "")}Displaying it in a Window.
function main() { Screen:PrintString("Goodbye, World!") while (B1 == false) { Screen:Render() }}importjava.awt.*importjavax.swing.*funmain(args:Array<String>){JOptionPane.showMessageDialog(null,"Goodbye, World!")// in alert boxwith(JFrame("Goodbye, World!")){// on title barlayout=FlowLayout()add(JButton("Goodbye, World!"))// on buttonadd(JTextArea("Goodbye, World!"))// in editable areapack()defaultCloseOperation=JFrame.EXIT_ON_CLOSEisVisible=true}}
This image is aVI Snippet, an executable image ofLabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.
1)weaddanew"alert"primitivetothelambdatalk'sdictionary{scriptLAMBDATALK.DICT["alert"]=function(){varargs=arguments[0];alert(args)};}2)andwecallit{alertGoodByeWorld}->displayastandardAlertWIndow.
On OS X machines:
sys_process('/usr/bin/osascript',(:'-e','display dialog "Goodbye, World!"'))->wait
NOTICE "Goodbye, world!"
Display in alert box:
_player.alert("Goodbye, World!")Display in main window ("stage"):
-- create a fieldm = new(#field)m.rect = rect(0,0,320,240)m.alignment = "center"m.fontsize = 24m.fontStyle = "bold"m.text = "Goodbye, World!"-- create sprite, assign field_movie.puppetSprite(1, TRUE)sprite(1).member = msprite(1).loc = point(0,105)-- force immediate update_movie.updateStage()
Works in HyperCard and other xTalk environments
answer "Goodbye, World!"
A dialog box can be modified as appropriate for the context by setting a "iconType", button text and title
answer warning "Goodbye, World!" with "Goodbye, World!" titled "Goodbye, World!"
gl_window("graphical hello world", 800, 600)gl_setfontname("data/fonts/Droid_Sans/DroidSans.ttf")gl_setfontsize(30)while gl_frame(): gl_clear([ 0.0, 0.0, 0.0, 1.0 ]) gl_text("Goodbye, World!")Among the turtle commands are some commands for drawing text in the graphical area. Details and capabilities differ among Logo implementations.
LABEL [Hello, World!]SETLABELHEIGHT 2 * last LABELSIZELABEL [Goodbye, World!]
require"iuplua"dlg=iup.dialog{iup.label{title="Goodbye, World!"};title="test"}dlg:show()if(notiup.MainLoopLeveloriup.MainLoopLevel()==0)theniup.MainLoop()end
To actually run this LÖVE-program, the following codeneeds to be in a filemain.lua, in its own folder.
This folder usually also contains other resources for a game,such as pictures, sound, music, other source-files, etc.
To run the program, on windows, drag that folder onto either love.exe or a shortcut to love.exe.
functionlove.draw()love.graphics.print("Goodbye, World!",400,300)end
A window with a click event to open a message box, and print returned number to window form, scrolling at the lower part of form's layer.
Module CheckIt { Declare Simple Form \\ we can define form before open Layer Simple { \\ center Window with 12pt font, 12000 twips width and 6000 twips height \\ ; at the end command to center the form in current screen Window 12, 12000, 6000; \\ make layer gray and split screen 0 Cls #333333, 0 \\ set split screen to 3rd line, like Cls ,2 without clear screen Scroll Split 2 Cursor 0, 2 } With Simple, "Title", "Hello Form" Function Simple.Click { Layer Simple { \\ open msgbox Print Ask("Hello World") Refresh } } \\ now open as modal Method Simple, "Show", 1 \\ now form deleted Declare Simple Nothing}CheckItA simple Window only
Module CheckIt { Declare Simple Form With Simple, "Title", "Hello World" Method Simple, "Show", 1 Declare Simple Nothing}CheckItMaplets:-Display(Maplets:-Elements:-Maplet(["Goodbye, World!"]));
CreateDialog["Hello world"]
msgbox('Goodbye, World!')
Add text to a graphical plot.
text(0.2,0.2,'Hello World!')
messageBox "Goodbye world"
GraphicsWindow.DrawText(5,5,"Goodbye, World!")
This implementation is for use with theMini Micro version of MiniScript.
import"textUtil"hello=textUtil.Dialog.make("Hello, World Dialog","Hello, World!")hello.show
alias goodbyegui { dialog -m Goodbye Goodbye}dialog Goodbye { title "Goodbye, World!" size -1 -1 80 20 option dbu text "Goodbye, World!", 1, 20 6 41 7}MODULEGUIHelloEXPORTSMain;IMPORTTextVBT,Trestle;<*FATAL ANY*>VARv:=TextVBT.New("Goodbye, World!");BEGINTrestle.Install(v);Trestle.AwaitDelete(v);ENDGUIHello.
This code requires an m3makefile.
import ("ui")implementation ("GUIHello")program ("Hello")This tells the compiler to link with the UI library, the file name of the implementation code, and to output a program named "Hello".
Whether the output is graphical or text depends largely the compiler with which the /.ROFF/ source code below is compiled.If it is compiled with an Nroff compiler, its output is comparable to that of a typewriter. Therefore, output from Nroff is typically seen on a text terminal. If it is compiled with a Troff compiler, its output is comparable to that of a typesetter. Therefore, output from Troff is typically seen on a PostScript or PDF output using a document viewer. Furthermore, output from Troff is also usually seen on paper, so that may count as graphical as well.In conclusion, although the code is compatible with both Nroff and Troff, it should be compiled using Troff to guarantee graphical output.
Because /.ROFF/ is a document formatting language in and of itself, it is extremely likely that a user of /.ROFF/ will be typing mostly textual content in a natural language. Therefore, there are no special routines or procedures to be called to output normal text, as all text will get formatted onto paper automatically.
Goodbye, World!
The NekoVM uses a C FFI that requires marshaling of C types to Nekovalue types.
/* Tectonics: gcc -shared -fPIC -o nekoagar.ndll nekoagar.c `agar-config --cflags --libs`*//* Neko primitives for libAgar http://www.libagar.org */#include<stdio.h>#include<neko.h>#include<agar/core.h>#include<agar/gui.h>#define val_widget(v) ((AG_Widget *)val_data(v))DEFINE_KIND(k_agar_widget);/* Initialize Agar Core given appname and flags */valueagar_init_core(valueappname,valueflags){#ifdef DEBUGif(!val_is_null(appname))val_check(appname,string);val_check(flags,int);#endifif(AG_InitCore(val_string(appname),val_int(flags))==-1)returnalloc_bool(0);returnalloc_bool(1);}DEFINE_PRIM(agar_init_core,2);/* Initialize Agar GUI given graphic engine driver */valueagar_init_gui(valuedriver){#ifdef DEBUGif(!val_is_null(driver))val_check(driver,string);#endifif(AG_InitGraphics(val_string(driver))==-1)returnalloc_bool(0);AG_BindStdGlobalKeys();returnalloc_bool(1);}DEFINE_PRIM(agar_init_gui,1);/* Initialize Agar given appname, flags and GUI driver */valueagar_init(valueappname,valueflags,valuedriver){#ifdef DEBUGif(!val_is_null(appname))val_check(appname,string);val_check(flags,int);if(!val_is_null(driver))val_check(driver,string);#endifif(!val_bool(agar_init_core(appname,flags)))returnalloc_bool(0);if(!val_bool(agar_init_gui(driver)))returnalloc_bool(0);returnalloc_bool(1);}DEFINE_PRIM(agar_init,3);/* end the Agar event loop on window-close */voidrundown(AG_Event*event){AG_Terminate(0);}/* Create an Agar window, given UInt flags (which might use 32 bits...) */valueagar_window(valueflags){#ifdef DEBUGval_check(flags,int);#endifAG_Window*win;win=AG_WindowNew(val_int(flags));AG_SetEvent(win,"window-close",rundown,"%p",win);if(win==NULL)returnalloc_bool(0);returnalloc_abstract(k_agar_widget,win);}DEFINE_PRIM(agar_window,1);/* Show a window */valueagar_window_show(valuew){AG_Window*win;#ifdef DEBUGval_check_kind(w,k_agar_widget);#endifwin=(AG_Window*)val_widget(w);AG_WindowShow(win);returnalloc_bool(1);}DEFINE_PRIM(agar_window_show,1);/* New box */valueagar_box(valueparent,valuetype,valueflags){AG_Box*b;#ifdef DEBUGval_check_kind(parent,k_agar_widget);#endifb=AG_BoxNew(val_widget(parent),val_int(type),val_int(flags));returnalloc_abstract(k_agar_widget,b);}DEFINE_PRIM(agar_box,3);/* New label */valueagar_label(valueparent,valueflags,valuetext){AG_Label*lw;#ifdef DEBUGval_check_kind(parent,k_agar_widget);#endiflw=AG_LabelNewS(val_widget(parent),val_int(flags),val_string(text));returnalloc_abstract(k_agar_widget,lw);}DEFINE_PRIM(agar_label,3);/* Event Loop */valueagar_eventloop(void){intrc;rc=AG_EventLoop();returnalloc_int(rc);}DEFINE_PRIM(agar_eventloop,0);
The C file above is used to create a Neko friendly Dynamic Shared Object file, nekoagar.ndll.The DSO functions are then loaded and exposed to Neko.
The Neko program follows:
/** <doc><pre> Hello world, graphical, in Neko, via Agar label Tectonics: gcc -shared -fPIC -o nekoagar.ndll rosetta-nekoagar.c `agar-config --cflags --libs` nekoc hello-graphical.neko neko hello-graphical </pre></doc>*//* Load some libagar bindings http://www.libagar.org/mdoc.cgi?man=AG_Intro.3 */varagar_init=$loader.loadprim("nekoagar@agar_init",3);varagar_window=$loader.loadprim("nekoagar@agar_window",1);varagar_window_show=$loader.loadprim("nekoagar@agar_window_show",1);varagar_box=$loader.loadprim("nekoagar@agar_box",3);varagar_label=$loader.loadprim("nekoagar@agar_label",3);varagar_eventloop=$loader.loadprim("nekoagar@agar_eventloop",0);/* Init with driver; NULL for best choice on current system */try{varrc=agar_init("nekoagar",0,val_null);if$not(rc)$throw("Error: agar_init non zero");}catche{$throw("Error: agar_init exception");}/* Put up a window, with a box, and a label in the box */varw=agar_window(0);varbox=agar_box(w,1,0);varlabel=agar_label(box,0,"Goodbye, World!");agar_window_show(w);/* Run the event loop */agar_eventloop();
prompt$ gcc -shared -DDEBUG -fPIC -o nekoagar.ndll rosetta-nekoagar.c `agar-config --cflags --libs`prompt$ nekoc hello-graphical.nekoprompt$ neko hello-graphical
Rosetta Code no longer supports uploading images, sorry.
Compile with:
ncc -reference:System.Windows.Forms goodbye.n
usingSystem;usingSystem.Windows.Forms;MessageBox.Show("Goodbye, World!")
UsingJava'sSwing Foundation Classes.
/* NetRexx */optionsreplaceformatcommentsjavacrossrefsymbolsbinaryimportjavax.swing.msgText='Goodbye, World!'JOptionPane.showMessageDialog(null,msgText)
An alternative version using other Swing classes.
/* NetRexx */optionsreplaceformatcommentsjavacrossrefsymbolsbinaryimportjavax.swing.msgText='Goodbye, World!'window=JFrame(msgText)text=JTextArea()minSize=Dimension(200,100)text.setText(msgText)window.setLayout(FlowLayout())window.add(text)window.setMinimumSize(minSize)window.packwindow.setVisible(isTrue)window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)returnmethodisTrue()publicstaticreturnsbooleanreturn1==1methodisFalse()publicstaticreturnsbooleanreturn\isTrue
An example usingJava'sAbstract Window Toolkit (AWT)
/* NetRexx */optionsreplaceformatcommentsjavacrossrefsymbolsbinaryclassRCHelloWorld_GraphicalAWT_01extendsDialogimplementsActionListenerpropertiesprivateconstantmsgText='Goodbye, World!'propertiesindirectok=booleancan=booleanokButton=ButtoncanButton=ButtonbuttonPanel=PanelmethodRCHelloWorld_GraphicalAWT_01(frame=Frame,msg=String,canaction=boolean)publicsuper(frame,'Default',isTrue)setLayout(BorderLayout())add(BorderLayout.CENTER,Label(msg))addOKCancelPanel(canaction)createFrame()pack()setVisible(isTrue)returnmethodRCHelloWorld_GraphicalAWT_01(frame=Frame,msg=String)publicthis(frame,msg,isFalse)returnmethodaddOKCancelPanel(canaction=boolean)setButtonPanel(Panel())getButtonPanel.setLayout(FlowLayout())createOKButton()ifcanactionthendocreateCancelButton()endadd(BorderLayout.SOUTH,getButtonPanel)returnmethodcreateOKButton()setOkButton(Button('OK'))getButtonPanel.add(getOkButton)getOkButton.addActionListener(this)returnmethodcreateCancelButton()setCanButton(Button('Cancel'))getButtonPanel.add(getCanButton)getCanButton.addActionListener(this)returnmethodcreateFrame()dim=getToolkit().getScreenSizesetLocation(int(dim.width/3),int(dim.height/3))returnmethodactionPerformed(ae=ActionEvent)publicifae.getSource==getOkButtonthendosetOk(isTrue)setCan(isFalse)setVisible(isFalse)endelseifae.getSource==getCanButtonthendosetCan(isTrue)setOk(isFalse)setVisible(isFalse)endreturnmethodmain(args=String[])publicconstantmainFrame=Frame()mainFrame.setSize(200,200)mainFrame.setVisible(isTrue)message=RCHelloWorld_GraphicalAWT_01(mainFrame,msgText,isTrue)ifmessage.isOkthensay'OK pressed'ifmessage.isCanthensay'Cancel pressed'message.disposemainFrame.disposereturnmethodisTrue()publicstaticreturnsbooleanreturn1==1methodisFalse()publicstaticreturnsbooleanreturn\isTrue
NewLISP uses a lightweight Java GUI server that it communicates with over a pipe, similar how some languages use Tcl/Tk. This takes advantage of Java's cross platform GUI capability.
; hello-gui.lsp; oofoe 2012-01-18; Initialize GUI server.(load(append(env"NEWLISPDIR")"/guiserver.lsp"))(gs:init); Create window frame.(gs:frame'Goodbye100100300200"Goodbye!")(gs:set-resizable'Goodbyenil)(gs:set-flow-layout'Goodbye"center"); Add final message.(gs:label'Message"Goodbye, World!""center")(gs:add-to'Goodbye'Message); Show frame.(gs:set-visible'Goodbyetrue); Start event loop.(gs:listen)(exit); NewLisp normally goes to listener after running script.
; Nehal-Singhal 2018-06-05>(!"dialog --msgbox GoodbyeWorld! 5 20"); A dialog message box appears on terminal similar to yes/no box.
importdialogs,gtk2gtk2.nim_init()info(nil,"Hello World")
importiupdiscardiup.open(nil,nil)message("Hello","Hello World")close()
10 LOCATE 6,1120 PRINT "GOODBYE, WORLD!"
;nyquist plug-in;version 4;type tool;name "Goodbye World"(print"Goodbye, World!")
;nyquist plug-in;version 4;type tool;codetype sal;name "Goodbye World"return "Goodbye, World!"
use Qt;bundle Default { class QtExample { function : Main(args : String[]) ~ Nil { app := QAppliction->New(); win := QWidget->New(); win->Resize(400, 300); win->SetWindowTitle("Goodbye, World!"); win->Show(); app->Exec(); app->Delete(); } }}To show a modal alert (Mac):
NSAlert*alert=[[NSAlertalloc]init];[alertsetMessageText:@"Goodbye, World!"];[alertrunModal];
To show a modal alert (iOS):
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Goodbye, World!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];
let delete_event evt = falselet destroy () = GMain.Main.quit ()let main () = let window = GWindow.window in let _ = window#set_title "Goodbye, World" in let _ = window#event#connect#delete ~callback:delete_event in let _ = window#connect#destroy ~callback:destroy in let _ = window#show () in GMain.Main.main ();;let _ = main () ;;
ocaml -I +labltk labltk.cma
Just output as a label in a window:
let () = let main_widget = Tk.openTk () in let lbl = Label.create ~text:"Goodbye, World" main_widget in Tk.pack [lbl]; Tk.mainLoop();;
Output as text on a button that exits the current application:
let () = let action () = exit 0 in let main_widget = Tk.openTk () in let bouton_press = Button.create main_widget ~text:"Goodbye, World" ~command:action in Tk.pack [bouton_press]; Tk.mainLoop();;
package mainimport "core:fmt"import "core:c"import "base:runtime"import "core:sys/windows"main :: proc () { lptextt:="Goodbye, World!" lptextw:= windows.utf8_to_wstring(lptextt, context.temp_allocator) lptext:= transmute([^]u16)lptextw lptextt2:="Title" lptextw2:= windows.utf8_to_wstring(lptextt2, context.temp_allocator) lptext2:= transmute([^]u16)lptextw2 lastid:u32 lastid= windows.MB_ICONWARNING // change last value from 0 to lastid to show warning dummy:=windows.MessageBoxW(nil,lptext,lptext2,0)}(import (lib winapi))(MessageBox #f (c-string "Hello, World!") (c-string "Rosettacode") #x40)
MESSAGE "Goodbye, World!" VIEW-AS ALERT-BOX.
Windows MessageBox:
print "Hello World!"

Requires a Glade GUI description file. 'ere be one I produced earlier:
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--><!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.24.dtd"><glade-interface><widget> <property name="visible">True</property> <property name="title">Hello World</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="default_width">200</property> <property name="default_height">100</property> <signal name="delete_event" handler="on_hworld_delete_event"/> <child> <widget> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">Farewell, cruel world.</property> </widget> </child></widget></glade-interface>
And finally the Oxygene:
// Display a Message in a GUI Window//// Nigel Galloway, April 18th., 2012.//namespace HelloWorldGUI;interfaceuses Glade, Gtk, System;type Program = public static class public class method Main(args: array of String); end; MainForm = class(System.Object) private var [Widget] hworld: Gtk.Window; public constructor(args: array of String); method on_hworld_delete_event(aSender: Object; args: DeleteEventArgs); end;implementationclass method Program.Main(args: array of String);begin new MainForm(args);end;constructor MainForm(args: array of String);begin inherited constructor; Application.Init(); with myG := new Glade.XML(nil, 'HelloWorldGUI.Main.glade', 'hworld', nil) do myG.Autoconnect(self); Application.Run();end;method MainForm.on_hworld_delete_event(aSender: Object; args: DeleteEventArgs);begin Application.Quit();end;end.
namespace HelloWorldNET;interfacetype App = class public class method Main; end; implementationclass method App.Main;begin System.Windows.MessageBox.Show("Farewell cruel world");end; end.declare [QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']} Window = {QTk.build td(label(text:"Goodbye, World!"))}in {Window show}print "Goodbye, World!"'Prints in the upper left corner of the window.
plotinit(1, 1, 1, 1);plotstring(1, "Goodbye, World!");plotdraw([1, 0, 15]);
Variant of the C example:
program HelloWorldGraphical;uses glib2, gdk2, gtk2;var window: PGtkWidget;begin gtk_init(@argc, @argv); window := gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), 'Goodbye, World'); g_signal_connect (G_OBJECT (window), 'delete-event', G_CALLBACK (@gtk_main_quit), NULL); gtk_widget_show_all (window); gtk_main();end.
// Hello world/Graphical. Nigel Galloway: January 16th., 2023begin System.Windows.Forms.MessageBox.Show('Farewell Cruel World!')end.Just output as a label in a window:
use strict;use warnings;use Tk;my $main = MainWindow->new;$main->Label(-text => 'Goodbye, World')->pack;MainLoop();
Output as text on a button that exits the current application:
use strict;use warnings;use Tk;my $main = MainWindow->new;$main->Button( -text => 'Goodbye, World', -command => \&exit,)->pack;MainLoop();
use strict;use warnings;use Gtk2 '-init';my $window = Gtk2::Window->new;$window->set_title('Goodbye world');$window->signal_connect( destroy => sub { Gtk2->main_quit; });my $label = Gtk2::Label->new('Goodbye, world');$window->add($label);$window->show_all;Gtk2->main;use strict;use warnings;use QtGui4;my $app = Qt::Application(\@ARGV);my $label = Qt::Label('Goodbye, World');$label->show;exit $app->exec;includepGUI.eIupOpen()IupMessage("Bye","Goodbye, World!")IupClose()
You can run this onlinehere. A few improvements are probably warranted, as in changes to pGUI.js and/or pGUI.css, but at least the language/transpiler side of things is pretty much complete.
---- pwa\phix\hello_world.exw-- ========================--withjavascript_semanticsincludepGUI.eIupOpen()Ihandlelbl=IupFlatLabel("World!","EXPAND=YES, ALIGNMENT=ACENTER")Ihandlndlg=IupDialog(lbl,"TITLE=Hello, RASTERSIZE=215x85")IupShow(dlg)ifplatform()!=JSthenIupMainLoop()dlg=IupDestroy(dlg)IupClose()endif
if (!class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n");}$wnd = new GtkWindow();$wnd->set_title('Goodbye world');$wnd->connect_simple('destroy', array('gtk', 'main_quit')); $lblHello = new GtkLabel("Goodbye, World!");$wnd->add($lblHello); $wnd->show_all();Gtk::main();(call 'dialog "--msgbox" "Goodbye, World!" 5 20)
To run:Start up.Clear the screen.Write "Goodbye, World!".Refresh the screen.Wait for the escape key.Shut down.
require "bitmap"local bmp = bitmap.of(200, 50)bmp:text("Goodbye, World!", 10, 10, color.white)bmp:view()programa { // includes graphics library and use an alias inclua biblioteca Graficos --> g // define WIDTH and HEIGHT integer constants const inteiro WIDTH = 200 const inteiro HEIGHT = 100 // main entry funcao inicio() { // begin graphical mode (verdadeiro = true) g.iniciar_modo_grafico(verdadeiro) // define window title g.definir_titulo_janela("Hello") // define window dimesions g.definir_dimensoes_janela(WIDTH, HEIGHT) // while loop enquanto (verdadeiro) { // define color to black(preto) and clear window g.definir_cor(g.COR_PRETO) g.limpar() // define color to white(branco) g.definir_cor(g.COR_BRANCO) // set text font size g.definir_tamanho_texto(32.0) // draws text g.desenhar_texto(0, HEIGHT / 3, "Hello, world!") // calls render function g.renderizar() } // end graphical mode g.encerrar_modo_grafico() }}In the general Postscript context, theshow command will render the string that is topmost on the stack at thecurrentpoint in the previouslysetfont. Thus a minimal PostScript file that will print on a PostScript printer or previewer might look like this:
%!PS% render in Helvetica, 12pt:/Helvetica findfont 12 scalefont setfont% somewhere in the lower left-hand corner:50 dup moveto% render text(Goodbye, World!) show% wrap up page display:showpage
FUNCTION PBMAIN() AS LONG MSGBOX "Goodbye, World!"END FUNCTION
New-Label "Goodbye, World!" -FontSize 24 -Show
$form = New-Object System.Windows.Forms.Form$label = New-Object System.Windows.Forms.Label$label.Text = "Goodbye, World!"$form.AutoSize = $true$form.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink$form.Controls.Add($label)$Form.ShowDialog() | Out-Null
Alternatively, simply as a message box:
[System.Windows.Forms.MessageBox]::Show("Goodbye, World!")Uses default Processing methods and variables.
fill(0, 0, 0);text("Goodbye, World!",0,height/2);Works with SWI-Prolog and XPCE.
A simple message box :
send(@display, inform, 'Goodbye, World !').
A more sophisticated window :
goodbye :- new(D, window('Goodbye')), send(D, size, size(250, 100)), new(S, string("Goodbye, World !")), new(T, text(S)), get(@display, label_font, F), get(F, width(S), M), XT is (250 - M)/2, get(F, height, H), YT = (100-H)/2, send(D, display, T, point(XT, YT)), send(D, open).#N canvas 321 432 450 300 10;#X obj 100 52 loadbang;#X msg 100 74 Goodbye\, World!;#X obj 100 96 print -n;#X connect 0 0 1 0;#X connect 1 0 2 0;
MessageRequester("Hello","Goodbye, World!")Using the Windows API:
MessageBox_(#Null,"Goodbye, World!","Hello")
import bpy# select default cubebpy.data.objects['Cube'].select_set(True)# delete default cubebpy.ops.object.delete(True) # add text to Blender scene bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])bpy.context.scene.collection.objects.link(font_obj) # camera center to textbpy.context.scene.camera.location = (2.5,0.3,10)# camera orient angle to textbpy.context.scene.camera.rotation_euler = (0,0,0)# change 3D scene to view from the cameraarea = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')area.spaces[0].region_3d.view_perspective = 'CAMERA'
import tkMessageBoxresult = tkMessageBox.showinfo("Some Window Label", "Goodbye, World!")Note: The result is a string of the button that was pressed.
from tkinter import messageboxresult = messagebox.showinfo("Some Window Label", "Goodbye, World!")import PyQt4.QtGuiapp = PyQt4.QtGui.QApplication([])pb = PyQt4.QtGui.QPushButton('Hello World')pb.connect(pb,PyQt4.QtCore.SIGNAL("clicked()"),pb.close)pb.show()exit(app.exec_())import pygtkpygtk.require('2.0')import gtkwindow = gtk.Window()window.set_title('Goodbye, World')window.connect('delete-event', gtk.main_quit)window.show_all()gtk.main()# HelloWorld for VPython - HaJo Gurt - 2014-09-20from visual import *scene.title = "VPython Demo"scene.background = color.gray(0.2)scene.width = 600scene.height = 400scene.range = 4#scene.autocenter = TrueS = sphere(pos=(0,0,0), radius=1, material=materials.earth)rot=0.005txPos=(0, 1.2, 0)from visual.text import *# Old 3D text machinery (pre-Visual 5.3): numbers and uppercase letters only:T1 = text(pos=txPos, string='HELLO', color=color.red, depth=0.3, justify='center')import vis# new text object, can render text from any font (default: "sans") :T2 = vis.text(pos=txPos, text="Goodbye", color=color.green, depth=-0.3, align='center')T2.visible=FalseLbl_w = label(pos=(0,0,0), text='World', color=color.cyan, xoffset=80, yoffset=-40) # in screen-pixelsL1 = label(pos=(0,-1.5,0), text='Drag with right mousebutton to rotate view', box=0)L2 = label(pos=(0,-1.9,0), text='Drag up+down with middle mousebutton to zoom', box=0)L3 = label(pos=(0,-2.3,0), text='Left-click to change', color=color.orange, box=0)print "Hello World" # ConsolecCount = 0def change(): global rot, cCount cCount=cCount+1 print "change:", cCount rot=-rot if T1.visible: T1.visible=False T2.visible=True else: T1.visible=True T2.visible=Falsescene.bind( 'click', change ) while True: rate(100) S.rotate( angle=rot, axis=(0,1,0) )
import wxapp = wx.App(False)frame = wx.Frame(None, wx.ID_ANY, "Hello, World")frame.Show(True)app.MainLoop()
from kivy.app import Appfrom kivy.uix.floatlayout import FloatLayoutfrom kivy.uix.button import Buttonfrom kivy.uix.popup import Popupfrom kivy.uix.label import Labelclass GoodByeApp(App): def build(self, *args, **kwargs): layout = FloatLayout() ppp = Popup(title='Goodbye, World!', size_hint=(0.75, 0.75), opacity=0.8, content=Label(font_size='50sp', text='Goodbye, World!')) btn = Button(text='Goodbye', size_hint=(0.3, 0.3), pos_hint={'center': (0.5, 0.5)}, on_press=ppp.open) layout.add_widget(btn) return layoutGoodByeApp().run()With kv language
from kivy.app import Appfrom kivy.lang.builder import Builderkv = '''#:import Factory kivy.factory.FactoryFloatLayout: Button: text: 'Goodbye' size_hint: (0.3, 0.3) pos_hint: {'center': (0.5, 0.5)} on_press: Factory.ThePopUp().open()<ThePopUp@Popup>: title: 'Goodbye, World!' size_hint: (0.75, 0.75) opacity: 0.8 Label: text: 'Goodbye, World!' font_size: '50sp''''class GoodByeApp(App): def build(self, *args, **kwargs): return Builder.load_string(kv)GoodByeApp().run() [ $ "turtleduck.qky" loadfile ] now! [ $ /import turtlesize = from_stack()words = string_from_stack()turtle.write(words,align="center", font=("Arial", size, "normal")) / python ] is write turtle 0 frames 255 times [ clear i^ 3 of colour $ "Goodbye, World!" i write frame ]File:Quackery Goodbye World.gif
Rather minimalist, but working...
library(RGtk2) # bindings to Gtkw <- gtkWindowNew()l <- gtkLabelNew("Goodbye, World!")w$add(l)#lang racket/gui(require racket/gui/base); Make a frame by instantiating the frame% class(define frame (new frame% [label "Goodbye, World!"])) ; Make a static text message in the frame(define msg (new message% [parent frame] [label "No events so far..."])) ; Make a button in the frame(new button% [parent frame] [label "Click Me"] ; Callback procedure for a button click: (callback (lambda (button event) (send msg set-label "Button click")))) ; Show the frame by calling its show method(send frame show #t)
(formerly Perl 6)
use GTK::Simple;use GTK::Simple::App;my GTK::Simple::App $app .= new;$app.border-width = 20;$app.set-content( GTK::Simple::Label.new(text => "Goodbye, World!") );$app.run;
MessageBox("Goodbye, World!", "RapidQ example", 0)import vis::Figure;import vis::Render;public void GoodbyeWorld() = render(box(text("Goodbye World")));MsgBox("Goodbye, World!")alert "Goodbye, World!"
>> view [ text "Hello World !"]
This REXX example only works with:
/*REXX (using PC/REXX) to display a message in a window (which is bordered). */if fcnPkg('rxWindow') ¬== 1 then do say 'RXWINDOW function package not loaded.' exit 13 endif pcVideo()==3 then normal= 7 else normal=13window#=w_open(1, 1, 3, 80, normal)call w_border window#call w_put window#, 2, 2, center("Goodbye, World!", 80-2) /*stick a fork in it, all we're done. */output
╔══════════════════════════════════════════════════════════════════════════════╗║ Goodbye, World! ║╚══════════════════════════════════════════════════════════════════════════════╝
This REXX example only works with:
and it creates two windows, the first (main) window contains the Goodbye, World! text,
the other "help" window contains a message about how to close the windows.
/*REXX program shows a "hello world" window (and another to show how to close)*/parse upper version !ver .; !pcrexx= !ver=='REXX/PERSONAL' | !ver=='REXX/PC'if ¬!pcrexx then call ser "This isn't PC/REXX" /*this isn't PC/REXX ? */rxWin=fcnPkg('rxwindow') /*is the function around?*/if rxWin¬==1 then do 1; 'RXWINDOW /q' if fcnPkg('rxwindow')==1 then leave /*the function is OK.*/ say 'error loading RXWINDOW !'; exit 13 endtop=1; normal=31; border=30; curpos=cursor()width=40; height=11; line.=; line.1= 'Goodbye, World!'w=w_open(2, 3, height+2, width, normal); call w_border w,,,,,borderhelpLine= 'press the ESC key to quit.'helpW=w_open(2, 50, 3, length(helpLine)+4, normal)call w_border helpw,,,,,border; call w_put helpW, 2, 3, helpLinecall w_hide w, 'n' do k=0 to height-1 _=top+k; call w_put w, k+2, 3, line._, width-4 end /*k*/call w_unhide w do forever; if inKey()=='1b'x then leave; end /* ↑ */call w_close w /* └──◄ the ESCape key.*/call w_close helpwif rxWin¬==1 then 'RXUNLOAD rxwindow'parse var curPos row colcall cursor row, col /*stick a fork in it, we're all done. */ Load "guilib.ring"New qApp { new qWidget() { setwindowtitle("Hello World") show() } exec()}Since visuals are already built in,this link does the same thing.
"Goodbye world!" MSGBOX
require 'gtk2'window = Gtk::Window.newwindow.title = 'Goodbye, World'window.signal_connect(:delete-event) { Gtk.main_quit }window.show_allGtk.mainrequire 'tk'root = TkRoot.new("title" => "User Output")TkLabel.new(root, "text"=>"CHUNKY BACON!").pack("side"=>'top')Tk.mainloop#_Note: this code MUST be executed through the Shoes GUI!!Shoes.app do para "CHUNKY BACON!", :size => 72end
require 'gosu'class Window < Gosu::Window def initialize super(150, 50, false) @font = Gosu::Font.new(self, "Arial", 32) end def draw @font.draw("Hello world", 0, 10, 1, 1, 1) end endWindow.new.show#_Note: this code must not be executed through a GUIrequire 'green_shoes'Shoes.app do para "Hello world"end
require 'win32ole'WIN32OLE.new('WScript.Shell').popup("Hello world")' do it with javascripthtml "<script>alert('Goodbye, World!');</script>"// cargo-deps: gtkextern crate gtk;use gtk::traits::*;use gtk::{Window, WindowType, WindowPosition};use gtk::signal::Inhibit;fn main() { gtk::init().unwrap(); let window = Window::new(WindowType::Toplevel).unwrap(); window.set_title("Goodbye, World!"); window.set_border_width(10); window.set_window_position(WindowPosition::Center); window.set_default_size(350, 70); window.connect_delete_event(|_,_| { gtk::main_quit(); Inhibit(false) }); window.show_all(); gtk::main();}Ad hoc solution asREPL script:
swing.Dialog.showMessage(message = "Goodbye, World!")
Longer example, as an application:
import swing._object GoodbyeWorld extends SimpleSwingApplication { def top = new MainFrame { title = "Goodbye, World!" contents = new FlowPanel { contents += new Button ("Goodbye, World!") contents += new TextArea("Goodbye, World!") } }}import swing._ object HelloDotNetWorld { def main(args: Array[String]) { System.Windows.Forms.MessageBox.Show ("Goodbye, World!") }}#!r6rs;; PS-TK example: display frame + label(import (rnrs) (lib pstk main) ; change this to refer to your PS/Tk installation )(define tk (tk-start))(tk/wm 'title tk "PS-Tk Example: Label")(let ((label (tk 'create-widget 'label 'text: "Goodbye, world"))) (tk/place label 'height: 20 'width: 50 'x: 10 'y: 20))(tk-event-loop tk)
messagebox("Goodbye, World!")pos -100 70print "Goodbye, World!"
This example waits until the mouse is clicked for the program to end. This can be useful if the program executes too fast for "Hello world!" to be visible on the screen long enough for it to be comfortable.
pos -100 70print "Goodbye, World!"delayOnClick
Seed7 does not work with an event handling function like gtk_main().The progam stays in control and does not depend on callbacks.The graphic library manages redraw, keyboard and mouse events.The contents of a window are automatically restored when it isuncovered. It is possible to copy areas from a window even whenthe area is currently covered or off screen.
$ include "seed7_05.s7i"; include "draw.s7i"; include "keybd.s7i"; include "bitmapfont.s7i"; include "stdfont24.s7i"; include "pixmap_file.s7i";const proc: main is func local var text: screen is STD_NULL; begin screen(400, 100); clear(curr_win, white); KEYBOARD := GRAPH_KEYBOARD; screen := openPixmapFontFile(curr_win); color(screen, black, white); setFont(screen, stdFont24); setPosXY(screen, 68, 60); write(screen, "Goodbye, World"); ignore(getc(KEYBOARD)); end func;
Answer "Good Bye"
var tk = require('Tk')var main = %O<MainWindow>.newmain.Button( '-text' => 'Goodbye, World!', '-command' => 'exit',).packtk.MainLoopvar gtk2 = require('Gtk2') -> init var window = %O<Gtk2::Window>.newvar label = %O<Gtk2::Label>.new('Goodbye, World!') window.set_title('Goodbye, World!')window.signal_connect(destroy => { gtk2.main_quit }) window.add(label)window.show_all gtk2.mainuse('Gtk3 -init')var gtk3 = %O'Gtk3'var window = %O'Gtk3::Window'.newvar label = %O'Gtk3::Label'.new('Goodbye, World!')window.set_title('Goodbye, World!')window.signal_connect(destroy => { gtk3.main_quit })window.add(label)window.show_allgtk3.mainThe gui module is an optional module when you compile the slope interpreter. With the module installed the following will produce a window with the text "Goodbye, world!" and the title of the window will be "Goodbye".
(define gui (gui-create))(gui-add-window gui "Goodbye")(window-set-content gui "Goodbye" (container "max" (widget-make-label "Goodbye, world!")))(window-show-and-run gui "Goodbye")
w = window()w.alert("Goodbye, World!")MessageBox show: 'Goodbye, world.'
'Hello World' asMorph openInWindow
Dialog information: 'Goodbye, world.'
DIALOG "Goodbye, world."
Ok, I know this is cheating. But it isn'tcompletely cheating: the SSEM uses Williams tube storage, so the memory is basically a CRT device; and this is an executable program, up to a point, because the first line includes a111 Stop instruction (disguised as a little flourish joining the tops of thed and theb).
011000000000011100000000000000001000000000000101000000000000000010011101110111011101010111000000100101010101010101010101010000001001010101010101010101011100000010011101110111011100110100000010100000000000000000000100110000101001100000000000000010000000010001101000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000100100100000000010000100100000001001001000000000100001001000000010010010111011101001110010000000100100101010100010010100100000001001001010101000100101000000000010010010111010001101110010000000011011000000000000000000000000
Once you've keyed it in, the first eighteen words of storage will look a bit like this:
oo oooo o oo ooo ooo ooo ooo o o oooo o o o o o o o o o o o oo o o o o o o o o o o oooo ooo ooo ooo ooo oo o oo o oo oo oo o o oo o o o o o o o o o o o o o o o o o ooo ooo o ooo o o o o o o o o o o o o o o o o o o o o o o o ooo o oo ooo o oo oo
Works with PolyML
open XWindows ;open Motif ; val helloWindow = fn () => let val shell = XtAppInitialise "" "demo" "top" [] [XmNwidth 400, XmNheight 300 ] ; val main = XmCreateMainWindow shell "main" [XmNmappedWhenManaged true ] ; val text = XmCreateLabel main "show" [ XmNlabelString "Hello World!"] in ( XtManageChildren [text]; XtManageChild main; XtRealizeWidget shell ) end;
call
helloWindow ();
window stopbox note "Goodbye, World!"
I want window and the window title is "Goodbye, World".
import Cocoalet alert = NSAlert()alert.messageText = "Goodbye, World!"alert.runModal()
\( Graphical Hello\)make main window:win =: new GTK window \ currently only top-levelwin::set title "Hello GTK"win::set size 200, 100win::connect 'destroy' to `GTK main quit`win::add widget (new GTK widget label "Hello!"):>win main (args):+GTK init argswin =: make main windowwin::show allGTK main win\+ stdlib\+ ./TAVPL_gtk.tavh
Just output as a label in a window:
pack [label .l -text "Goodbye, World"]
Output as text on a button that exits the current application:
pack [button .b -text "Goodbye, World" -command exit]
Note: If you name this program "button.tcl", you might get strange errors.
Don't use the name of any internal tcl/tk-command as a filename for a tcl-script.
This shows our text in a message box:
tk_messageBox -message "Goodbye, World"
PROGRAM:GUIHELLO:Text(0,0,"GOODBYE, WORLD!")
Dialog Text "Goodbye, World!"EndDlog
when flag clickedsay "Goodbye, World!"stop this script
SET WINDOW 0, 320, 0, 200SET COLOR "YELLOW"BOX AREA 20,50,40,60SET COLOR "GREEN"PLOT TEXT, AT 25, 45: "Goodbye, World!"END
(with-dyn-lib "user32.dll" (deffi messagebox "MessageBoxW" int (cptr wstr wstr uint)))(messagebox cptr-null "Hello" "World" 0) ;; 0 is MB_OK
Using whiptail or dialog
whiptail --title 'Farewell' --msgbox 'Goodbye, World!' 7 20
dialog --title 'Farewell' --msgbox 'Goodbye, World!' 7 20
Using the simple dialog command xmessage, which uses the X11 Athena Widget library
xmessage 'Goodbye, World!'
Using the zenity modal dialogue command (wraps GTK library) available with many distributions ofLinux
zenity --info --text='Goodbye, World!'
Using yad (a fork of zenity with many more advanced options)
yad --title='Farewell' --text='Goodbye, World!'
The following code is altered from the TheIDE example page. It displays a blank GUI with a menu. Click on about from the menu and the goodbye world prompt appears.
#include <CtrlLib/CtrlLib.h>// submitted by Aykayayciti (Earl Lamont Montgomery)using namespace Upp;class GoodbyeWorld : public TopWindow {MenuBar menu;StatusBar status;void FileMenu(Bar& bar);void MainMenu(Bar& bar);void About();public:typedef GoodbyeWorld CLASSNAME;GoodbyeWorld();};void GoodbyeWorld::About(){PromptOK("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Goodbye World sample}}");}void GoodbyeWorld::FileMenu(Bar& bar){bar.Add("About..", THISBACK(About));bar.Separator();bar.Add("Exit", THISBACK(Close));}void GoodbyeWorld::MainMenu(Bar& bar){menu.Add("File", THISBACK(FileMenu));}GoodbyeWorld::GoodbyeWorld(){AddFrame(menu);AddFrame(status);menu.Set(THISBACK(MainMenu));status = "So long from the Ultimate++ !";}GUI_APP_MAIN{SetLanguage(LNG_ENGLISH);GoodbyeWorld().Run();}|00 @System [ &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1 ]|20 @Screen [ &vector $2 &width $2 &height $2 &auto $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]|100@on-reset ( -> )( size )#00a8 .Screen/width DEO2#0020 .Screen/height DEO2( theme ) #3ce9 .System/r DEO2 #0b75 .System/g DEO2 #2b59 .System/b DEO2 #001c .Screen/x DEO2 #000a .Screen/y DEO2;my-string draw-textBRK@draw-text ( text* -- )[ LIT2 15 -Screen/auto ] DEO&>while ( -- )LDAk #00 SWP DUP2( addr ) #20 SUB #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2( move ) ;font/widths ADD2 LDA #00 SWP .Screen/x DEI2 ADD2( draw ) [ LIT2 01 -Screen/sprite ] DEOk DEO.Screen/x DEO2INC2 LDAk ?&>whilePOP2 JMP2r@my-string "Goodbye 20 "World! 0a00@font&widths [0800 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000808 0808 0808 0808 0808 0808 0808 08080808 0808 0808 0808 0808 0808 0808 08080808 0808 0808 0808 0808 0808 0808 08080808 0808 0808 0808 0808 0808 0808 08080808 0808 0808 0808 0808 0808 0808 08080808 0808 0808 0808 0808 0808 0808 0800 ]&glyphs [ ( starting from 0x20 )0000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1818 1818 1818 1800 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000066 6666 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 6c6c 6cfe 6c6c fe6c 6c6c 0000 00000000 0000 0000 0000 0000 0000 0000 00000010 107c d6d0 d07c 1616 d67c 1010 00000000 0000 0000 0000 0000 0000 0000 00000000 66d6 6c0c 1818 3036 6b66 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 386c 6c38 76dc cccc dc76 0000 00000000 0000 0000 0000 0000 0000 0000 00000018 1818 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0c18 3030 3030 3030 180c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3018 0c0c 0c0c 0c0c 1830 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 006c 38fe 386c 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0018 187e 1818 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 1818 3000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 00fe 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0606 0c0c 1818 3030 6060 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6ce def6 e6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1838 7818 1818 1818 187e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c606 0c18 3060 c0fe 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c606 3c06 06c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 060e 1e36 66c6 fe06 0606 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fec0 c0c0 fc06 0606 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3c60 c0c0 fcc6 c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fe06 060c 0c18 1830 3030 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 7cc6 c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 c67e 0606 0c78 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0018 1800 0000 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0018 1800 0000 1818 3000 00000000 0000 0000 0000 0000 0000 0000 00000000 0006 0c18 3060 3018 0c06 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00fe 0000 fe00 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0060 3018 0c06 0c18 3060 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 0c18 1800 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 ced6 d6d6 d6ce c07e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 c6fe c6c6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fcc6 c6c6 fcc6 c6c6 c6fc 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c0 c0c0 c0c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 f8cc c6c6 c6c6 c6c6 ccf8 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fec0 c0c0 f8c0 c0c0 c0fe 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fec0 c0c0 f8c0 c0c0 c0c0 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c0 c0de c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 c6c6 fec6 c6c6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3c18 1818 1818 1818 183c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1e0c 0c0c 0c0c 0ccc cc78 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 ccd8 f0f0 d8cc c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c0c0 c0c0 c0c0 c0c0 c0fe 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 82c6 eefe d6c6 c6c6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 c6e6 f6de cec6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 c6c6 c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fcc6 c6c6 c6fc c0c0 c0c0 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c6c6 c6c6 c6c6 de7c 0600 00000000 0000 0000 0000 0000 0000 0000 00000000 fcc6 c6c6 c6fc f0d8 ccc6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7cc6 c0c0 7c06 06c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 ff18 1818 1818 1818 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 c6c6 c6c6 c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 c6c6 c66c 6c6c 3838 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 c6c6 c6d6 feee c682 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c6c6 6c6c 3838 6c6c c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c3c3 6666 3c18 1818 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 fe06 060c 1830 60c0 c0fe 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3c30 3030 3030 3030 303c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 6060 3030 1818 0c0c 0606 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3c0c 0c0c 0c0c 0c0c 0c3c 0000 00000000 0000 0000 0000 0000 0000 0000 00000018 3c66 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 00fe 00000000 0000 0000 0000 0000 0000 0000 00003018 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007c 067e c6c6 c67e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 c0c0 c0fc c6c6 c6c6 c6fc 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007c c6c0 c0c0 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0606 067e c6c6 c6c6 c67e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007c c6c6 fec0 c07c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1e30 30fc 3030 3030 3030 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007e c6c6 c6c6 c67e 0606 7c000000 0000 0000 0000 0000 0000 0000 00000000 c0c0 c0fc c6c6 c6c6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1818 0038 1818 1818 183c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0606 000e 0606 0606 0606 6666 3c000000 0000 0000 0000 0000 0000 0000 00000000 c0c0 c0c6 ccd8 f0d8 ccc6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3818 1818 1818 1818 183c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00fc d6d6 d6d6 d6d6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00fc c6c6 c6c6 c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007c c6c6 c6c6 c67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00fc c6c6 c6c6 c6fc c0c0 c0000000 0000 0000 0000 0000 0000 0000 00000000 0000 007e c6c6 c6c6 c67e 0606 06000000 0000 0000 0000 0000 0000 0000 00000000 0000 00de f0e0 c0c0 c0c0 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 007e c0c0 7c06 06fc 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 3030 30fc 3030 3030 301e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00c6 c6c6 c6c6 c67e 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00c6 c6c6 6c6c 3838 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00c6 c6d6 d6d6 d67c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00c6 c66c 386c c6c6 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 0000 00c6 c6c6 c6c6 c67e 0606 7c000000 0000 0000 0000 0000 0000 0000 00000000 0000 00fe 0c18 3060 c0fe 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1c30 3030 6030 3030 301c 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 1818 1818 1818 1818 1818 0000 00000000 0000 0000 0000 0000 0000 0000 00000000 7018 1818 0c18 1818 1870 0000 00000000 0000 0000 0000 0000 0000 0000 00000073 dbce 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 0000 ]

#!/usr/local/bin/vala --pkg gtk+-3.0using Gtk;void main(string[] args) { Gtk.init(ref args); var window = new Window(); window.title = "Goodbye, world!"; window.border_width = 10; window.window_position = WindowPosition.CENTER; window.set_default_size(350, 70); window.destroy.connect(Gtk.main_quit); var label = new Label("Goodbye, world!"); window.add(label); window.show_all(); Gtk.main();}Public Sub hello_world_gui() MsgBox "Goodbye, World!"End Sub
MsgBox("Goodbye, World!")Displaying the message on status line. The message remains visible until the next keystroke, but macro execution continues.
Statline_Message("Goodbye, World!")Displaying a dialog box with the message and default OK button:
Dialog_Input_1(1,"`Vedit example`,`Goodbye, World!`")
There are several ways to do this. From Normal mode, one way (which requires Vim version 8.2 with patch 1522) is:
:call popup_notification("Hello world", {})Another way (which requires Vim version 9.0 with patch 337) is:
:echow "Hello world"
NB: Neither of these will work with Neovim.
Sub Main() MsgBox "Goodbye, World!"End Sub
Imports System.Windows.FormsModule GoodbyeWorld Sub Main() Messagebox.Show("Goodbye, World!") End SubEnd Module* Version 1:MESSAGEBOX("Goodbye, World!") * Version 2:? "Goodbye, World!"import uifn main() { ui.message_box('Hello World')}@1Introduction.Define the structure of the program.@aPROGRAM goodbye world CONTEXT VOID USE standardBEGIN@<Included declarations@>@<Logic at the top level@>ENDFINISH@ Include the graphical header file.@iforms.w@>@ Program code.@<Logic...@>=open(LOC FILE,"",arg channel);fl initialize(argc,argv,NIL,0);fl show messages("Goodbye World!");fl finish@ Declare the necessary macros.@<Include...@>=macro fl initialize;macro fl show messages;macro fl finish;@ The end.print 1 at 10,12 "Hello world!"end
import "graphics" for Canvas, Colorclass Game { static init() { Canvas.print("Goodbye, World!", 10, 10, Color.white) } static update() {} static draw(alpha) {}}This example used the Windows MessageBox function to do the work for us.Windows uses the stdcall calling convention where the caller pushesfunction parameters onto the stack and the stack has been fixed upwhen the callee returns.
;;; hellowin.asm;;;;;; nasm -fwin32 hellowin.asm;;; link -subsystem:console -out:hellowin.exe -nodefaultlib -entry:main \;;; hellowin.obj user32.lib kernel32.lib global _main extern _MessageBoxA@16 extern _ExitProcess@4 MessageBox equ _MessageBoxA@16 ExitProcess equ _ExitProcess@4 section .text_main: push 0 ; MB_OK push title ; push message ; push 0 ; call MessageBox ; eax = MessageBox(0,message,title,MB_OK); push eax ; call ExitProcess ; ExitProcess(eax);message: db 'Goodbye, World',0title: db 'RosettaCode sample',0
;use win32ax for 32 bit;use win64ax for 64 bitinclude 'win64ax.inc'.code start: invoke MessageBox,HWND_DESKTOP,"Goodbye,World!","Goodbye",MB_OK invoke ExitProcess,0.end start
Not sure if ncurses counts as 'graphical', but whatver..
option casemap:noneprintfproto :qword, :varargexitproto :dword;; curses.h stuffinitscrproto ;; WINDOW *initsrc(void);endwinproto ;; int endwin(void);start_colorproto ;; int start_color(void);wrefreshproto :qword ;; int wrefresh(WINDOW *w);wgetchproto :qword ;; int wgetch(WINDOW *w)waddnstrproto :qword, :qword, :dword;; int waddnstr(WINDOW *w, const char *str, int n);;; Just a wrapper to make printing easier..printlnproto :qword, :qword.codemain proc local stdscr:qwordcall initscrmov stdscr, raxcall start_colorinvoke println, stdscr, CSTR("Goodbye, World!",10)invoke wgetch, stdscrcall endwininvoke exit, 0retmain endpprintln proc wnd:qword, pstr:qwordinvoke waddnstr, wnd, pstr, -1invoke wrefresh, wndretprintln endpendoption casemap:nonegtk_mainprotogtk_main_quitprotogtk_window_get_typeprotogtk_widget_show_allproto :qwordexitproto :dwordgtk_window_newproto :dwordprintf proto :dword, :varargg_type_check_instance_castproto :qword, :qwordgtk_initproto :qword, :qwordgtk_window_set_title proto :qword, :qwordg_signal_connect_dataproto :qword, :qword, :qword, :dword, :dword, :dworddel_event proto.datatltdb "hello_gtk",0agc dq 1agv dq agsagsdq tltdq 0.codemain proclocal hwnd:qwordlocal tmp:qwordinvoke printf, CSTR("-> Starting GTK with argc:%i - argv ptr: 0x%x",10), agc, agvlea rax, agclea rbx, agvinvoke gtk_init, rax, rbxinvoke gtk_window_new, 0mov hwnd, raxinvoke printf, CSTR("-> Main window handle: %d",10), hwndcall gtk_window_get_typemov tmp, raxinvoke printf, CSTR("-> Window type: %d",10), tmpinvoke g_type_check_instance_cast, hwnd, tmpmov tmp, raxinvoke gtk_window_set_title, tmp, CSTR("Goodbye, World.")invoke g_type_check_instance_cast, hwnd, 0x50mov tmp, raxlea rax, del_eventinvoke g_signal_connect_data, tmp, CSTR("delete-event"), rax, 0, 0, 0invoke gtk_widget_show_all, hwndcall gtk_main;invoke exit, 0retmain endpdel_event procinvoke printf, CSTR("-> Exit event called..",10)call gtk_main_quitretdel_event endpendThis sets up a 320x200x8 (VGA) graphics screen and writes text on it.
[SetVid($13); Text(6, "Goodbye, World!")]
The output is an SVG document. The idea is that it's straightforward to use XSLT to turn an existing SVG into an instantiable template.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="xml"/><xsl:template match="/*"><!--Use a template to insert some text into a simple SVG graphicwith hideous colors.--><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"><rect x="0" y="0" width="400" height="200" fill="cyan"/><circle cx="200" cy="100" r="50" fill="yellow"/><text x="200" y="115"style="font-size: 40px;text-align: center;text-anchor: middle;fill: black;"><!-- The text inside the element --><xsl:value-of select="."/></text></svg></xsl:template></xsl:stylesheet>
Sample input:
<message>Goodbye, World!</message>
Sample output (with formatting non-destructively adjusted):
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"><rect x="0" y="0" width="400" height="200" fill="cyan"/><circle cx="200" cy="100" r="50" fill="yellow"/><text x="200" y="115">Goodbye, World!</text></svg>
open window 200, 100text 10, 20, "Hello world"color 255, 0, 0 : text 10, 40, "Good bye world", "roman14"
zkl doesn't have a decent GUI ffi but, on my Linux box, the following work:
System.cmd(0'|zenity --info --text="Goodbye, World!"|); // GTK+ pop upSystem.cmd(0'|notify-send "Goodbye, World!"|); // desktop notificationSystem.cmd(0'|xmessage -buttons Ok:0,"Not sure":1,Cancel:2 -default Ok -nearmouse "Goodbye, World!" -timeout 10|); // X Windows dialog
The quote quote syntax is 0'<char>text<char> or you can use \ (eg "\"Goodbye, World!\"")