As couple of side-notes,
The
print statement makes unique use of the semi-colon, which acts differently to the colon, but they can be thought of in a similar way: while a colon says to run the next command on the same line, the semi-colon says to output the next
print command on the same output line. If you want to output multiple strings on the same line you only need one
print statement. Here are some examples:
print "Hello ";"World!"
print "Hello ";
print "World!"
Note 2
Colons are also used to define labels, these are like bookmarks in the program. Labels that end with a return statement are called subroutines, this is because they are routines that can be placed outside of the main code and called via the
gosub command, when all the code inside the subroutine has been executed and the program comes across the
return statement it will return to the place directly after the subroutine was called in the main code.
do
gosub hello
loop
hello:
print "hello world?"
return
You can also jump straight to a label by using
goto, although this command is rarely used any more since there are so many better ways to control the program flow, and making large jumps around program can quickly disorientate any reader trying to follow it, since
goto does not return to where it was called.
Unfortunately, the use of the same symbol (the colon) as both a line delimiter and label definition creates a conflict between the two, and as such, labels require their own line. I.E. the following code will not work as desired:
do : gosub hello : loop: hello: print "HELLO" : return
Meanwhile...