OWBasic for Pocketviewer

Home INTRO Group CONTROL Alphabetical Index

Conditional Execution of Instructions

IF <Condition> THEN <Instructions>: ENDIF
IF <Condition> THEN <Instruction1>: ELSE <Instruction2>: ENDIF
IF <Condition> GOTO <label>

Conitional execution of instructions. If the condition is fulfilled, then the instructions between THEN and ENDIF or THEN and ELSE are executed.
In the second form the instructions between ELSE and ENDIF are executed, if the condition is not fulfilled.

A condition is any boolean (logical) expression.

Example:

IF a>b THEN
   ? "A is greater than B"
ELSE
   ? "A is smaller or equal to B"
ENDIF

IF a % 2=0 THEN PRINT "A is even": ENDIF
In the form IF <instruction> GOTO <label> with fulfilled condition a jump to the label is executed. This is a short form for the instructions:

IF <condition> THEN GOTO <label>: ENDIF

Home INTRO Group CONTROL Alphabetical Index