Go to the first, previous, next, last section, table of contents.


Statements

There are the following statements in this language

Assignment statements

Assignment statements are of the form :-

qualIdent := EXPRESSION

The value of the expression is stored in the variable referenced by the identifier. A qualIdent is an identifier that can be one of the following forms :-

See See section References for discussion of qualIdent. See See section Expressions for discussion of expressions.

If statements.

'If' statements come in two forms :-

if expression then
  statements;
  statements;
   .
   .
   .
endif;

or in the form

if expression then
  statements;
   .
   .
else
  statements;
   .
   .
endif;

If the expression evaluates as positive (>0) (See See section The Boolean convention) the statements directly after the then are executed, otherwise they are skipped, and the statements after the else (if present) are executed.

Both if statements and if-then-else statements must be terminated by the keyword endif

These statements can be nested to arbitary depths...

if optimal then
  if mullet < 2.0 then
    .......
  else
    ....
  endif;
else
  if TewateBay.level > 2 then
    ........
  endif;
endif;

Print statements.

This enables one to print an expression.

  print mullet;
  print 1*2;
  print "First year ", (f1+f2+f3+f4)/4;

There are two forms of the print statement.

  PRINT expression;

Just prints out the value of that expression everytime it is evaluated.

  PRINT "STRING", expression;

Prints out the STRING followed by the value of the expression.

SHOW statement.

This is really simple.

  SHOW qualIdent;

Simply prints out the name of the variable followed by ':=' followed by its value.

TRACE statement.

Syntax :-

  TRACE expression;

If expression evaluates to true, then trace every pseudo-assembler instruction, else switch tracing off.

The following are equivalent and switch tracing on...

  TRACE true;
  TRACE 1;
  TRACE 20*30;

The following are equivalent and switch tracing off...

  TRACE false;
  TRACE -1;
  TRACE -100;

Increment and Decrement.

These are basically shorthand variants of the assignment statement.

  qualIdent += EXPRESSION;

The result of evaluating the EXPRESSION is added to the value referenced by the identifier.

  qualIdent -= EXPRESSION;

The result of evaluating the EXPRESSION is subtracted from the value referenced by the identifier.

If mullet had the value 1.0, then executing

  mullet += 2.0;

would result in mullet having the value 3.0;

Caveats!

The identifier must have been initialised elsewhen... The result of this is undefined...

specie mullet;
running rules;
  mullet += 2.0; // What are we adding 2.0 to?
end specie; 

We should of had something like

specie mullet;
mullet := 1;
running rules;
  mullet += 2.0; //  We are adding 2.0 to 1.0 in the first step.
end specie; 

Caveat 2. These may look like C operators, behave like C operators, but they are NOT operators. They are statements. In C you can write

  confusion = mullet -= croc += 1;

The use of side effect operators in C allows one to write marvellously obfusticated code, which nobody can hope to read without developing sharp head-aches. The purpose of this language is to allow easy to use and read and modify code. Therefore use of += and -= in expressions has been explicitly banned.

References

A reference is a mechanism for identifying a particular entity or storage location. For example, if you referred to step_size the compiler would give you access to the memory storing the step size used by the model.

The following discussion refers to example rules and data given in the See section Brief example. You may wish to take a look at that and then come back here by pressing the l (for last screen) key.

Now with cell based species things become a bit more complicated :-

In the example we have the declaration specie squeaky_duck;. (See See section Specie declarations.)

This declares a cell based specie squeaky_duck and also creates the following identifiers squeaky_duck@this_cell, squeaky_duck@that_cell and squeaky_duck@the_other_cell.

Further along we have the statement squeaky_duck -= 0.9;, which identifier gets modified? The answer is, when the running rules are executed, they are executed for each cell. Thus squeaky_duck@this_cell, squeaky_duck@that_cell and squeaky_duck@the_other_cell will get modified.

In the example we also have the expression birdwatchers in [30,infinity], but in the input file we have this_cell.birdwatchers, that_cell.birdwatchers, the_other_cell.birdwatchers. On input, the program mashes these names to fit the variable@cellName convention. Thus the input file would give use variables of the name birdwatchers@this_cell, birdwatchers@that_cell, birdwatchers@the_other_cell.

If a variable in the input file is found to be present for all cells, then an cell based identifier corresponding to that variable is created. (eg. birdwatchers Again, the system automagically sorts out which data stream we want from the variable name and the current cell.


Go to the first, previous, next, last section, table of contents.