index

Varkon MBS Programmers manual

# Statements

Statements are the things that actually do the job in a module. There are five types of statements: Assignment, IF, FOR, GOTO, and procedure call.

## Assignment

An assignment has the following form...

      variable:=expression;

where expression is any valid expression for the type of variable to recieve its value.

## The IF statement

An IF statement has the following form:

      IF condition THEN
        statements
      [ELIF condition THEN
        statements]
      [ELSE
        statements]
      ENDIF;

The ELIF and ELSE keywords are optional. A condition is a logical expression including relational operators and keywords AND, OR and NOT.

Here is an example:

      IF a < min OR a > max THEN
        statements
      ELSE
        statements
      ENDIF;

## The FOR statement

A for statement has the following form:

      FOR loop_variable:=start TO stop [STEP increment] DO
        statements
      ENDFOR;

The loop_variable is an ordinary INT variable while start, stop and increment are any integer expressions. Evaluation of these is done once before the loop is entered and their values can not be altered from within the loop. The STEP value may be positive or negative.

A sample FOR loop:

      FOR i:=1 to 10 DO
        poi_free(#1,vec(i,0)); ! 10 Points on a row
      ENDFOR;

## The GOTO statement

A goto statement is used to jump to a label as in the following example:

      IF a > max THEN
        GOTO error;
      ENDIF;

      error:

As you see from this example a label is just an identifier followed by a colon.

## Procedure calls

There are four types of procedures in MBS.

### 1. Ordinary procedures

A call to an ordinary procedure has the following form:

      identifier([expressions]);

### 2. Geometric procedures

A call to a geometric procedure has the following form:

      identifier(#integer, [expressions] [:attributes]);

Geometric procedures are used to create entities with #integer as ID. Attributes are things like PEN and LEVEL, see below.

### 3. The part procedure

The part procedure has two forms:

      part(#integer, part_name([parameters]) [,reference_expression] [:attributes]);

      part(#integer, string_expression, ([parameters]) [,reference_expression]);

In the first form the part name is a constant while the other form accepts an expression.

### 4. The set procedure

The set procedure also has two forms:

      set(attributes);

      set_basic(attributes);

Multiple attributes may be specified by separating them with commas.

      set(LEVEL=1,TFONT=0,LDASHL=10/s);

      set_basic(PSIZE=2.5);

For a complete list of attributes see the set procedure.

Varkon version 1.19C svn# 97