Declaring and Managing Variables

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs

PGM Syntax Data Types Declaring Variables Predefined Variables Labels


Introduction

  • 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.

Data Types

Please see page Data Types for more information.

Declaring Variables

Please see page Declaring Variables for more information.

Labels

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).

Class/Function Call Syntax Example Description
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
  • InstanceName : an instance of the class, declared above.
  • dataMember : is a data member belonging to the predefined instance
  • value : is the value to be assigned to the data member.
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
  • InstanceName : an instance of the class, declared above.
  • dataMember : a data member belonging to the predefined instance.
  • variable : a pre-declared variable
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()
  • InstanceName : an instance of the class, declared above or predefined.
  • memberFunction : is a function declared within the predefined instance
  • variable : is a pre-declared variable, its value is returned by memberFunction.
SpeciesIndex = SDB.FindSpecies("H2O(l)") Getting the species index of water from the Species Database Class