The FOR statement repeatedly executes a block of statements while incrementing a specified control variable for each execution of the statement block. FOR loops can be conditional or unconditional and can modify other statements. Examples FOR I% = 1% TO 10% STEP 2% . . . NEXT I% FOR N% = 5% STEP 4% WHILE 400 - Z < .0001 . . . NEXT N% . . . PRINT I% ** I% FOR I% = 1% TO 3%
1 – Syntax
Unconditional: FOR num-unsubs-var = num-exp1 TO num-exp2 [ STEP num-exp3 ] [ statement ]... NEXT num-unsubs-var Conditional: {UNTIL} FOR num-unsubs-var = num-exp1 [STEP num-exp3] {WHILE} cond-exp [ statement ]... NEXT num-unsubs-var Unconditional Statement Modifier: statement FOR num-unsubs-var = num-exp1 TO num-exp2 [STEP num-exp3] Conditional Statement Modifier: statement FOR num-unsubs-var = num-exp1 [step num- exp3] {WHILE} cond-exp