[↑]
IF
- CodeBlock1 is executed when the value of the expression is true (other than 0)
IF Expression THEN CodeBlock1
IF Expression THEN CodeBlock1 ELSE CodeBlock2
- CodeBlock1 is executed when the value of the expression is true (other than 0)
IF Expression THEN [LineFeed] CodeBlock1 ENDIF
IF Expression THEN [LineFeed] CodeBlock1 ELSE [LineFeed] CodeBlock2 ENDIF
- Branch to label when expression is true (other than 0)
IF Expression GOTO @Label [ELSE CodeBlock]
1. CodeBlock1 is executed when the value of the expression is true (other than 0)
IF Expression THEN CodeBlock1
IF Expression THEN CodeBlock1 ELSE CodeBlock2
If there is ELSE, execute CodeBlock2 when false (0)
・It's possible to not specify GOTO right after THEN and ELSE.
Example
IF A==1 THEN PRINT OK
IF A>1 THEN @JMP1 ELSE PRINT DATE$
@JMP1
END
2. CodeBlock1 is executed when the value of the expression is true (other than 0)
IF Expression THEN [LineFeed] CodeBlock1 ENDIF
IF Expression THEN [LineFeed] CodeBlock1 ELSE [LineFeed] CodeBlock2 ENDIF
If there is ELSE, execute CodeBlock2 when false (0)
・If a line feed occurs immediately after THEN or ELSE, multiple lines can be written in CodeBlock1 or CodeBlock2.
・When a line feed occurs immediately after THEN or ELSE, describe ENDIF at the end to clearly display the end of the IF statement.
Example
IF A==1 THEN
PRINT "Congratulations"
BEEP 2
ELSE
PRINT "Too bad"
ENDIF
3. Branch to label when expression is true (other than 0)
IF Expression GOTO @Label [ELSE CodeBlock]
Notes on using character strings for labels
・Label strings can also be used for labels.
・Strings cannot be used when GOTO is not specified immediately after ELSE.
Bad) IF A==0 GOTO "@LABEL1" ELSE "@LABEL2"
Good) IF A==0 GOTO "@LABEL1" ELSE @LABEL2
Good) IF A==0 GOTO "@LABEL1" ELSE GOTO "@LABEL2"
Example
IF A==1 GOTO @MAIN
IF X<0 GOTO @JMP1 ELSE PRINT A$
IF Y==5 GOTO @JMP1 ELSE @JMP2
@JMP1
PRINT "@JMP1"
@JMP2
PRINT "@JMP2"
END
About this site
Our site is an unofficial manual site of programming software "SmileBASIC" for NintendoSwitch™.
I acquire the content of the site from the
official reference site
of the
SmileBoom Co.Ltd.
that is the development and sales cause of the software in real time (a minimum period of 24 hours update) and display it.
For automatic update, contents may become improper.
Please confirm the correct content in an official site.
June 3, 2020
by mim
OK
|