|Token code:||254/$FE 24/$18|
in BASIC ROM:
|List of all BASIC keywords|
Type: Command General Programming-Syntax: IF Condition THEN BEGIN : statement statement statement BEND : ELSE BEGIN statement statement BEND
A conditional statement like IF...THEN:ELSE structured so that you can include several program lines between the start (BEGIN) and end (BEND) of the structure. Here's the format:
0 IF X=1 THEN BEGIN: PRINT "X=1 IS TRUE" 20 PRINT "So this part of the statement is performed" 30 PRINT "When X equals 1" 40 BEND: PRINT "End of BEGIN/BEND structure": GOTO 60 50 PRINT "X does not equal 1":PRINT "The statements between BEGIN/BEND are skipped" 60 PRINT "Rest of Program"
IF the conditional (IF..THEN) statement is line 10 is true, the statements between the keywords BEGIN and BEND are performed, including all the statements on the same line as BEND. If the (IF...THEN) conditional statement in line 10 is FALSE, all statements between the BEGIN and BEND, including the ones on the same program line as BEND are skipped, and the program resumes with the first program line immediately following the line containing BEND. The BEGIN/BEND essentially treats lines 10 through 40 as one ling line.
The same rules are true if the ELSE:BEGIN clause is specified. If the condition is true, all statements between ELSE:BEGIN and BEND are performed, including all statements on the same line as BEND. If false, the program resumes with the line immediately following the line containing BEND