FANDOM


It is possible to put two, or more, commands onto one line in SmileBasic. Use : between the commands to do this reliably.

Note that a : in the THEN or ELSE branch of an IF will be considered a separator of commands within that branch, not a separator of the IF command from the next command. For example, consider IF condition THEN do1:do2. This is not interpreted as two commands (first command IF with do1 in its THEN branch, and second command do2) - it is interpreted as one IF command, with both do1 and do2 in its THEN branch. In order to have another command follow an IF, it must be on a separate line (or, to get the same effect, it may be duplicated in all the branches).

But sometimes : is not necessary, when it is clear the end of one command is reached and whatever follows must be the beginning of another command. For example, A=19:PRINT "Hi" can also be written A=19PRINT "Hi", because A=19 makes sense but A=19P does not, so the P must be the start of a new command. Likewise INPUT A$PRINT A$ will work without a command separator, as will INPUT A PRINT A. Note however that A=&H13PRINT"Hi" will generate a Syntax error, as will A=&B10011PRINT"Hi". Also, : is always necessary to separate a PRINT command from the next command, and it is impossible to put a command on the same line after a REM (or ') command.

Finally, there are special considerations with labels. A label declaration cannot be on the same line as any command. If the label declaration is at the beginning of a line, followed by a :, the system generates a Syntax error. If the label declaration is at the beginning of the line and is followed by a space, then the space and anything after is ignored. If the label declaration is not at the beginning of a line, it is ignored, along with anything that follows on that line. A command that ends in a label (such as GOSUB, ON ... GOTO, and ON ... GOSUB) must also have a separator after it if another command follows on the same line, or the following commands will be ignored.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.