Predefined Constants and Variables

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs ➔ PGM Programming and Conventions ➔ Predefined Constants and Variables

PGM Syntax Data Types Declaring Variables Predefined Variables Formatting

Introduction

Constants can be used in expressions and statements, they are effectively read only variables. You can declare your own constants using the Const Keyword.

SysCAD Predefined Constants are listed in the following headings.

Standard constants

Type Predefined Constant Predefined Value Conversion Units Definition
BIT TRUE = 1
BIT FALSE = 0
REAL PI = 3.14159265358979
REAL NAN = * (see also IsNAN in Mathematical Functions)
REAL Gc = 9.80665 (Gravitational constant in m/s2) ("Accel", "m/s^2")
REAL Rgc = 8.314472 (Universal Gas Constant in J/mol.K) ("S(Ml)", "J/Mol.K")
REAL StdT = 25.0 (Standard Temperature in dC) ("T", "dC")
REAL StdP = 101.325 (Standard Pressure in kPa) ("P", "kPa")
LONG MaxLong = 2147483647 (Maximum value for Integer/Long data type)
LONG MinLong = -2147483648 (Minimum value for Integer/Long data type)

Special constants

Type Predefined Constant Predefined Value
STR ModelTag This contains the tag of the model that is using the PGM.
It refers to the parent or owner of the PGM code. For example, this is useful for Log messages to distinguish between different General Controller models using PGM code.

Special variable

Type Predefined Constant Predefined Value
BIT StopSimulation If this is set to 1 (true) then the PGM halts the SysCAD run.
This is useful for running a scenario for a fixed time or for stopping SysCAD under certain conditions.
The StopSolver() function can be used as an alternative, see Predefined functions.
BIT PauseSimulation If this is set to 1 (true) then the PGM pauses the SysCAD run.
The PauseSolver() function can be used as an alternative, see Predefined functions.

Reserved Variables

Some variable names are "reserved" and cannot be used when defining user defined variables. These include:

OLD Special Constants - to be removed in future builds

The following constants can still be used in SysCAD 9.3 up to Build139, if the Old135Format tickbox is checked in the General Controller:
Old135format.png
However, they will be removed in future updates. Please consider changing these to Trigger Subroutines as soon as possible.

Type Predefined Constant Predefined Value
BIT OnInitialise = 1 for the first iteration when the SysCAD run command is passed but before it is executed.
= 0 for all subsequent iterations.
This can be used to set tags that will become unchangeable once SysCAD is solving, which includes tags such as solving methods, any list boxes or tick boxes and datum in Dynamic.
Note: SetDynTag(Tag, value) and GetDynTag(Tag) must be used to do this.

Please change this to one of the Trigger Subroutines: Initialise PreStart, PreStart and InitialiseSolution .

BIT OnTerminate = 1 for the last iteration when the SysCAD stop command is passed.
= 0 for all other situations.
This can be used to the check condition of the solve solution and generate user defined messages based on the results.

Please change this to the Trigger Subroutine: TerminateSolution