Declaring and Managing Variables
|PGM Syntax||Data Types||Declaring Variables||Predefined Variables||Labels|
- Variables must be declared as one of the permissible Data types, shown below.
- A variable may be positioned anywhere in the PGM code, as long as it is declared before it is used.
- Any number of variables of the same data type may be declared together by separating each one with a comma, e.g. real SolidsFlow, LiquidsFlow, MetalRecovery
- When declaring variables, some optional keywords/symbols can be assigned to the variable for added functionality. Some of the common keywords are summarised in the table below, Common Options for Variable declaration. A list of all options is given at: All Options when Declaring variables.
- Users may also conceal variables based on a based on a test. Please see Conceal Variables.
Please see page Data Types for more information.
Please see page Declaring Variables for more information.
Please see page Labels for more information.
Classes: declarations and access to members
The declaration of an instance of a class is similar to the declaration of a variable, except that the instance must be declared from a predefined class. See Class, EndClass Keywords.
An instance may be positioned anywhere in the PGM code, as long as it is declared before it is used.
A * CANNOT be appended to the instance name. Use the Watch Keyword.
The first three examples below are based on the CSTR example class described on the Class page. The last one is based on the Predefined Species Database Class. The Species Database Class does not need to be declared and can only return values (no values can be set).
|Declaration of the Class instance||ClassName InstanceName(s)||CSTR TankA||Creating an instance of the CSTR Class, TankA.|
|Setting the value of a data member of an instance|| InstanceName.dataMember = value
||TankA.UnitTag = "TANK_A"||Setting the unit tag name (an alternative to using the Init function)|
|Retrieving the value of a data member of an instance|| variable = InstanceName.dataMember
||ReactionExtent = TankA.CuLeachExtent||Getting the calculated value of the Cu Leach reaction extent|
|Retrieving the value returned by a member function of an instance|| variable = InstanceName.memberFunction()
||SpeciesIndex = SDB.FindSpecies("H2O(l)")||Getting the species index of water from the Species Database Class|