Control structures
BlueZone Basic has complete process control functionality. The control structures available are Do loops, While loops, For loops, Select Case, If Then, and If Then Else. In addition, BlueZone Basic has one branching statement: GoTo. The Goto statement branches to the label specified in the Goto statement.
Example:
Goto label1

   .
   .
   .
 
label1:
The program execution jumps to the part of the program that begins with the label label1:.
Do loops
The Do...Loop allows you to execute a block of statements an indefinite number of times. The variations of the Do...Loop are Do While, Do Until, Do Loop While, and Do Loop Until.
Example:
Do While|Until condition
   statement(s)...
   [Exit Do]
   statement(s)...
Loop
 
Do Until condition 
   statement(s)...
Loop
 
Do 
   statements...
Loop While condition
 
Do 
   statements...
Loop Until condition
Do While and Do Until check the condition before entering the loop, thus the block of statements inside the loop are only executed when those conditions are met. Do Loop While and Do Loop Until check the condition after having executed the block of statements thereby guaranteeing that the block of statements is executed at least once.
While loop
The While...Wend loop is similar to the Do While loop. The condition is checked before executing the block of statements comprising the loop.
Example:
While condition
   statements...
Wend
For...Next loop
The For...Next loop has a counter variable and repeats a block of statements a set number of times. The counter variable increases or decreases with each repetition through the loop. The counter default is one if the Step variation is not used.
Example:
For counter = beginning value To ending value [Step increment]
   statements...
Next
If and Select statements
The If...Then block has a single line and multiple line syntax. The condition of an If statement can be a comparison or an expression, but it must evaluate to True or False.
Example:
If condition Then statements...   ' Single line syntax.
 
If condition Then
   ' Multiple line syntax.
   statements...
End If
The other variation on the If statement is the If...Then...Else statement. Use this statement when there are different statement blocks to be executed depending on the condition. There is also the If...Then...ElseIf... variation, these can get quite long and cumbersome, at which time consider using the Select statement.
Example:
If condition Then
   statements...
ElseIf condition Then
   statements...
Else
 
End If
The Select Case statement tests the same variable for many different values. This statement tends to be easier to read, understand, and follow and should be used in place of a complicated If...Then...ElseIf statement.
Example:
Select Case variable to test
   Case 1
      statements...
   Case 2
      statements...
   Case 3
      statements...
   Case Else
      statements...
End Select
Refer to Select Case statement for exact syntax and more code examples.