Program Flow 

The following constructs are available for controlling program flow.

If ... Then ... EndIf

If {expression} Then {statements1} Else {statements2} EndIf

Evaluates the 'If' expression and, if true, executes the 'Then' statements. If false, the 'Else' statement are executed, the 'Else' part is optional - statements are executed until the end of the line.

If {expression1}
ElseIf {expression2}
ElseIf {expression3}

This form of the If statement allows for more than one line of statements. The 'Else If' and 'Else' parts are optional. The 'Else' part is executed only if none of the 'If' or 'ElseIf' expressions were true. The 'EndIf' Keyword is required to close the condition.


In BlitzScript3D Labels are variables that store an Instruction's Address value. using the 'Goto' Command, the VM will jump to the instruction stored in the Label. Although very simple Labels and Goto can provide a very powerful means of progamram flow control. Practically all other program flow constructs can be simulated with them.

;For var = 1 To 10 Step 1;
Label for_1
If var< n Then
print("do stuff")
goto(endfor_1) ;exit for_1;
Goto(for_1) ;next;
Label endfor_1

Note: That Label Variables are regular variables and there is no protection at this
time to prevent overwritting.


The following Statements are to be implemented.

While ... Wend

While {expression}


A While loop continues executing until {expression} evaluates to false. {expression} is evaluated at the start of each loop.

For ... Next

For {variable}={initalvalue} To {finalvalue} Step {step}

A For/Next loop first assigns {initialvalue} to {variable} and then starts looping. The loop continues until {variable} reaches {finalvalue} and then terminates. Each loop, the value {step} is added to {variable}. If a step value is omitted, a default value of 1 is used.

For {variable}=Each {typename}

This form of the For/Next loop allows you to iterate over all objects of a custom type.

Repeat ... Until/Forever


Until {expression}

A Repeat loop continues executing until {expression} evaluates to true. {expression} is evaluated at the end of each loop.


A Repeat/Forever loop simply executes {statements} until the program ends, or an 'Exit' command is executed.

Select ... Case



Select {expression}
     Case {expressions1}
     Case {expressions2}

First the 'Select' expression is evaluated. It is then compared with each of the 'Case' expression lists. If it matches a 'Case', then the statements in the 'Case' are executed.

If the 'Select' expression matches none of the 'Case' expressions, the statements in the optional 'Default' section are executed.

Breaking Out Of A Loop

The 'Exit' command may be used to break out of any For...Next, While...Wend, Repeat...Until or Repeat...Forever loop.