When to use :
(or not)
The :
character is used as a statement-breaker in SB. Basically, you use it to stack statements on one line like so:
PRINT "HELLO!":PRINT "GOODBYE!"
Otherwise, your average statement is broken by a newline:
PRINT "HELLO!"
PRINT "GOODBYE!"
In reality, you often don't need to use the colon at all. So long as statements can be broken into syntactically valid tokens, the parser tends to figure out when one ends and the other starts. The same often goes for whitespace.
PRINT"HELLO!"PRINT"GOODBYE!"
Of course, this doesn't always work. There are always ambiguous cases and invalid syntaxes where you have to explicitly break statements. Take for example:
PRINT "HELLO";END
The semicolon means that PRINT
is expecting another expression to print out, unless the statement breaks there (we use dangling semicolons to suppress the newline.) Here it assumes END
is supposed to be a value, despite being a keyword, and tries to print it, resulting in an error. Thus, we have to explicitly break this statement, be it the colon or the newline.
In general, if something seems ambiguous, try it to see if it works. If it doesn't, break the statement. In addition, anything that would produce invalid syntax isn't highlighted correctly as 12Me21 mentioned.
All strings are truthy. Even empty ones. – snail_ – 2017-02-07T16:34:22.517
Ah, okay. Makes sense. – Rɪᴋᴇʀ – 2017-02-07T16:36:26.897