Closed rickcollette closed 1 month ago
With FastBasic, you only include THEN for single statement afterward:
IF A=1 THEN PRINT "HELLO"
If you include a :
after your THEN, it will not be considered as part of the check, and will always execute. This is the opposite of Atari BASIC.
IF A=1 THEN PRINT "A IS 1": PRINT "THIS WILL DISPLAY EVEN WHEN A IS NOT 1"
If you want to span multiple lines/commands, simply remove THEN
A=1:B=2
IF A = 1
PRINT "Hello World - A is 1"
IF B = 2
PRINT "Hello World - B is 2"
ELSE
PRINT "Hello World - B is not 2"
ENDIF
ELIF A = 2
PRINT "Hello World - A is 2"
ELIF A = 3
PRINT "Hello World - A is 3"
ELSE
PRINT "Hello World - A is not 1, 2, or 3"
ENDIF
In FastBASIC, a new line and :
are considered the same thing, so the above could be written as:
IF A = 1:PRINT "Hello World - A is 1":IF B = 2:PRINT "Hello World - B is 2":ELSE:PRINT "Hello World - B is not 2"
... (I did not copy the entire thing but you get the point)
This is explained in the manual: https://github.com/dmsc/fastbasic/blob/master/manual.md#control-statements
Scroll down a bit to Conditional Execution
It took me a bit to get used to it, but now I really like this convention.
Excellent - thank you! Yeah - I think its a case of "slow down and get it right.." for me :)
I am going loopy trying to figure out the most basic of basic things in ... basic...
I would LOVE an example of this working: