Hello world programs in Basic
The following example works for any ANSI/ISO-compliant BASIC implementation, as well as most implementations built into or distributed with microcomputers in the 1970s and 1980s (usually some variant of Microsoft BASIC):
10 PRINT "Hello, world!" 20 END
Note that the "END" statement is optional in many implementations of BASIC.
Some implementations could also execute instructions in an immediate mode when line numbers are omitted. The following examples work without requiring a RUN instruction.
PRINT "Hello, world!"
? "Hello, world!"
Later implementations of BASIC allowed greater support for structured programming and did not require line numbers for source code. The following example works when RUN for the vast majority of modern BASICs.
PRINT "Hello, world!" END
Again, the "END" statement is optional in many BASICs.
Print "Hello, world!" WaitKey
PRINT "Hello, world!"
TEXT 0,0,"Hello, world!" WAIT KEY
Note: In the "classic" Dark Basic the WAIT KEY command is optional as the console goes up when the program has finished.
PRINT "Hello World" SLEEP END
PRINT "Hello World"
? "Hello World"
'without a newline ? "Hello World";
AddText "Hello, world!" DrawScreen WaitKey
10 PRINT "Hello, World!" 20 END
To write to the main window:
print "Hello, world"
Or drawn in a graphics window:
nomainwin open "Hello, world!" for graphics as #main print #main, "place 50 50" print #main, "\Hello, world!" print #main, "flush" wait
Microsoft Small Basic
DEBUG "Hello, world!", CR
or, the typical microcontroller Hello, world! program equivalent with the only output device present being a light-emitting diode (LED) (in this case attached to the seventh output pin):
DO HIGH 7 'Make the 7th pin go high (turn the LED on) PAUSE 500 'Sleep for half a second LOW 7 ' Make the 7th pin go low (turn the LED off) PAUSE 500 'Sleep for half a second LOOP END
sub main print "Hello, world!" end sub
OpenConsole() PrintN("Hello, world!") Input()
MessageRequester("Hello, World","Hello, World")
Debug "Hello, World"
On TI calculators of the TI-80 through TI-86 range:
:Disp "Hello, world! (note the optional ending quotes) :Output(X,Y,"Hello, world! (note the optional ending parenthesis) :Text(X,Y,"Hello, world! (writes to the graph rather than home screen) :Text(-1,X,Y,"Hello, world! (only on the 83+ and higher, provides larger text, home screen size) :"Hello, world! (last line of program only)
Note: "!" character is not on the keypad. It can be accessed from "Catalog" menu, "Probability" menu, or "Math" menu (as factorial notation).
On TI-89/TI-89 Titanium/TI-92(+)/Voyage 200 calculators:
:hellowld() :Prgm :Disp "Hello, world!" :EndPrgm
Public Sub Main() Debug.Print "Hello, world!" End Sub
Public Sub Main() MsgBox "Hello, world!" End Sub
Private Sub Form_Activate() Print "Hello, world!" End Sub
Alternatively, copy this into a New Form:
Private Sub Form_Click() Form1.Hide Dim HelloWorld As New Form1 HelloWorld.Width = 2500: HelloWorld.Height = 1000: HelloWorld.Caption = "Hello, world!": HelloWorld.CurrentX = 500: HelloWorld.CurrentY = 75 HelloWorld.Show: HelloWorld.Font = "Tahoma": HelloWorld.FontBold = True: HelloWorld.FontSize = 12: HelloWorld.Print "Hello, world!" End Sub
Visual Basic .NET
Module HelloWorldApp Sub Main() System.Console.WriteLine("Hello, world!") End Sub End Module
PICK/BASIC, DATA/BASIC, MV/BASIC
In addition to the ANSI syntax at the head of this article, most Pick operating system flavors of Dartmouth BASIC support extended syntax allowing cursor placement and other terminfo type functions for VDT's
X, Y positioning (colon ":" is the concatenation instruction):
PRINT @(34,12) : "Hello, world!"
Will display the string "Hello, world!" roughly centered in a 80X24 CRT.
PRINT @(-1) : @(34,12) : "Hello, world!"
Will clear the screen before displaying the string "Hello, world!" roughly centered in a 80X24 CRT.
CRT "Hello, world!"
Supporting the "@" functions above, the CRT statement ignores previous PRINTER statements and always sends output to the screen.
Some Pick operating system environments such as OpenQM support the DISPLAY variant of PRINT. This variant in addition to the "@" functions maintains pagination based upon the settings of the TERM variable:
DISPLAY "Hello, world!"