index

Varkon MBS Programmers manual


Variables and constants

Variables

Variables (and constants) are declared after all parameters but before BEGINMODULE. A variable declaration reminds of a value_parameter_declaration without default_value or prompt_string.

  INT   i,j;    ! Two INT variables
  FLOAT size;   ! A FLOAT variable
  FILE  input_data,output_data; ! More than one variable separeted by commas

Variables may be indexed...

  INT   list(100);    ! Array of 100 integers
  FLOAT matrix(20,50) ! A 2-dimensional matrix 20 by 50
  FLOAT k(10,5,20,6)  ! A 4-dimensional matrix

and declared with upper and lower limit.

  INT    list(20:50);    ! An array of 31 integers
  FLOAT  matrix(0:3,0:3) ! A 4 by 4 matrix
  STRING names(0:9)*20;  ! An array of 10 names

If no lower limit is specified MBS uses a lower limit of 1 as default.

Constants

A constant is like a variable but may not be indexed and may not have its value changed. Instead its value is defined once and for all in its declaration...

  CONSTANT FLOAT  max_diameter=20.0;
  CONSTANT STRING error_message="Diameter is too large !";

The FILE type may not be used as a constant.

Here is a module with some variables and constants:

  !*********************************
  !*
  MODULE init_array();
  !*
  !*********************************
  !*
  INT   i;
  FLOAT k(100);

  CONSTANT INT min=1,max=100;

  BEGINMODULE

  for i:=min to max do
    k(i):=0.0;
  endfor;

  ENDMODULE
  !*
  !*********************************

SourceForge.net Logo

Varkon 1.19D svn # 120M