Scripting Language Elements


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.

    Goto label1

        .

        .

        .

 

    label1:

 

The program execution jumps to the part of the program that begins with the label "label1:".

Loop Structures

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.

    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.

    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.

    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.

    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.  This statement should be used when there is 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 you should consider using the Select statement.

    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.

    Select Case variable to test

        Case 1

            statements...

        Case 2

            statements...

        Case 3

            statements...

        Case Else

            statements...

    End Select

 

SEE  Select Case Statement in Language Reference A - Z, for exact syntax and code examples.