10.4.2.9. IF~ELSEIF~ELSE~ENDIF
10.4.2.9. IF~ELSEIF~ELSE~ENDIF
Explanation | Program is branched according to condition. Or, blocs after this statement are executed or not executed. | ||
Grammar | Simple sentence IF | IF <condi.> THEN <addr.> [ELSE <addr.>] IF <condi.> THEN CALL <program No.> IF <condi.> THEN JMPP <program No.> IF <condi.> THEN GOSUB <addr.> | |
Compound sentence IF | IF <condi.> THEN ~ [ELSEIF <condi.> THEN ~ ] [ELSE ~ ] ENDIF | ||
Parameter | Condition | Arithmetic formula, string condition formula | If 0, true. If not, false. |
Address | THEN: If the condition is true, the address is branched. ELSE: If the condition is false, the address is branched. |
| |
Example | Example of simple sentence IF | IF V2!>SQR(V50!^2+V51!^2) THEN 150 ELSE *AGAIN | |
Example of compound sentence IF | IF GI1>=10 THEN PRINT #0, "HIGH" PRINT #1, "HR-MSG: HIGH" ELSEIF GI1>=0 THEN PRINT #0, "LOW" ELSE GOTO *ERR ENDIF |