next up previous contents
Next: User input Up: Programming Help Previous: The structure of a

Conditionals and loops

   Loops of fixed size are best handled by

FOR j=1 to 10 STEP .5 ... NEXT j.

STEP is optional, and if none is given, then 1 is used by default.

Example858

Conditional action is accomplished by

IF ... THEN ... ELSE ... END IF

END IF is required only when multiple lines of instructions are to be executed.

Selection from several cases is perhaps easiest through

SELECT var ...
CASE 0 ...
CASE .5 ...
CASE ELSE
END SELECT

Conditional loops (the ones that last indefinitely, unless special circumstance is encountered) can be programmed through

WHILE cond ... WEND

or through

DO

....

IF cond THEN EXIT DO

...

LOOP

Other ways of breaking out of DO ... LOOP are available, too.

Example867

Exercise869



Send comment