next up previous
Next: NODES Up: DECLARATIONS Previous: CONST

VAR

Variables declared in the DECL section are global to the model program, i.e., they may be used anywhere in the program.

Variables declared in a node are local to that node and can only be used in the node's code. Their values are not retained after node processing.

Variables declared in the MESSAGES subsection of the DECL section, are fields of each generated message and may have different values in different messages. Field variables are variables introduced by the GLIDER system, one for each field name in messages, having the name of the field. They are global, and change their values each time a message is processed, taking the values of the corresponding fields of the processed messages. Note that if messages of different structure have fields of the same name they must be of the same type, and GLIDER introduces for them only one field variable.

Example:

    MESSAGES Cans(Diameter, Height, Weight: REAL);
             Packages(Length, Wide, Height, Weight: REAL);
The fields Height and Weight are in both record messages. Field variables having these names are system created so different messages may share same processes on these characteristics.

The declaration of variables reserves memory for them.

After the VAR specification one or more declarations of the following type follow:

<list of variable names> : <type>;

The <list of variable names> consists of one identifier or many identifiers separated by commas.

<type> may be a predefined type identifier, a user defined type identifier or a type specification written with the same syntax given for type declarations.

Examples:

    DECL
    TYPE
         VecType = (Small, Large, Truck);
         Color = (Rer_L, Yellow_L, Green_L);
         VecChar = RECORD Size, Weight: REAL; VType: VecType; END;
    VAR  VMax, Length, Slope: REAL;
         Ntotal, j, k: INTEGER; Semaf: Color;
         Vehicle: ARRAY[1 .. 30] of VecChar;
         Connections: ARRAY[1 .. 5, 1 .. 8] of BOOLEAN;
         X, Y: CONT;
         InpFreq: ARRAY[1 .. 4, 1 .. 3] OF FREQ;
         TabVeh: TEXT;


domingo c
Mon Mar 20 11:09:25 PST 2000