Download DUINOMITE USERS MANUAL
Transcript
IF ... THEN ... ELSE/ELSEIF...ENDIF Multi line IF Statement Purpose: To make a decision regarding program flow based on the result returned by an expression. Syntax: IF expression THEN statement(s) [ELSE statement(s)] [ENDIF] IF expression THEN statement(s) [ELSEIF expression THEN statement(s)] [ENDIF] Comments: If the result of expression is nonzero (logical true), the statements after THEN are executed, otherwise the statements after ELSE are executed. THEN and ELSE may be followed by either a line number for branching, or one or more statements to be executed. Example: In the following example, a test determines if N is greater than 10 and less than 20. If N is within this range, execution branches to line 200. If N is not within this range, execution continues with line 110. 100 FOR A = 3 TO 7 110 PRINT A 120 IF A < 5 THEN 130 PRINT "A < 5" 140 ELSEIF A = 5 THEN 150 PRINT "A = 5" 160 ELSE 170 PRINT "A > 5" 180 ENDIF 190 NEXT