English
Language : 

NSB8 Datasheet, PDF (50/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
IF
grifo®
ITALIAN TECHNOLOGY
STATEMENT:
IF <logical expression> THEN <statement>
IF <logical expression> THEN <statement> ELSE <statement>
ACTION:
When the logical expression is true, the statement after the word THEN is executed. When the
condition is false, the statement after ELSE (if it is used) is executed. If no ELSE is specified, and
the condition is false, the IF statement is ignored and execution continues with the next statement in
sequential order. A single line number may be placed after THEN or ELSE, and is equivalent to (and
shorthand for) a GOTO statement referencing that line number.
EXAMPLES:
10 IF X=5 THEN 1000
100 IF A$=”CLYDE” THEN PRINT “HI” ELSE PRINT “BAD PW”
75 IF Q(7) <>3 AND W THEN GOSUB 110 ELSE LET X=15
230 IF A$=”HI” THEN IF B$=”THERE” THEN PRINT “YES?”
999 IF Z THEN END
REMARKS:
Only the THEN or ELSE part of an IF statement (never both) will be executed for each time the IF
statement itself is executed.
The statement after THEN or ELSE may itself be an IF statement. Such multiple IFs are said to be
nested. There is, of course, a rather small practical limit as to how deeply IFs may be nested, since
the whole statement must fit on one line.
ERROR MESSAGES:
IF statement do not usually cause error messages in and of themselves. Errors which occur during
the execution of an IF statement may usually be attributed to the type of statement used in either its
THEN or ELSE clause, or the misformation of the logical expression. Check the section on the
appropriate type of statement or feature to track down tha cause of each individual error.
SEE ALSO:
Section USING NUMBERS
Statemen GOTO
Page 38
NSB8
Rel. 5.10