Predefined Control Statements

Parent Previous Next

Predefined Control Statements.

The compiler is able to recognize a number of predefined statement structures:

If Then Else , Case Of , For Loop , Repeat Until , While Loop , Try Catch.




If Then Else

This structure is defined as


   If BooleanExpression Then

   {

     //Then-block with statements is mandatory.

   }

   Else

   {

     //Else-block with statements is conditional.

   }


The Else { } part can be left out.




Case Of

This structure is defined as


   Case A

   {

     B, C, D {

         //Statements in case A matches one of them

       }

     X, Y {

         //XY-code-block

       }

     Else {

         //Statements in case no match was found

       }

   }


The Else { } part is conditional and can be left out.


All the specified characters A, B, C, D, X, Y symbolizes an expression of some sort. Each expression can contain functions which are executed in order to return a value.


However, you can't be sure that all expressions are evaluated/executed. If A matches B none of the other expressions are evaluated.

If A matches X or Y then the associated XY-code-block is executed. None of the other code blocks are used.




For Loop.

This structure exists in these two versions


   Integer I; //The loop index I


   For I := A To B

   {

     //Statements executed for each iteration.

     //The loop index I increments automatically.

   }


   For I := B Downto A

   {

     //Statements executed for each iteration.

     //The loop index I decrements automatically.

   }


The expressions A and B must return an integer, and they are evaluated only once - before the loop is started.




Repeat Until.

This structure is defined as


   Repeat

   {

     //Statements executed for each repetition.

   } Until StopExpression;


Evaluation of StopExpression must return a boolean. It is evaluated after each repetition.




While Loop.

This structure is defined as


   While KeepRunning

   {

     //Statements executed for each loop.

   }


The expression KeepRunning must return a boolean. It is evaluated before each loop.




Try Catch

This structure is defined as


   Try

   {

     //Try-block with statements.

   }

   Catch

   {

     //Catch-block with statements.

   }


The statements of the Catch-block are only executed if an error occur in the Try-block.