Predefined Constants and Variables
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.
To use predefined variables in a PGM file, simply reference them directly without declaring them.
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) |
Examples
;--- Variable declarations ---
Real Area@("Area", "m^2"), Radius*("L", "m")
; PI is a predefined constant in SysCAD, so it can be used directly without declaration.
Area = PI * Radius^2
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. |
Reserved Variables
Some variable names are "reserved" and cannot be used when defining user defined variables. These include:
- variables listed in the Standard constants list
- variables listed in the Special constants list
- variables listed in the Special variables list
- names used by predefined functions: Mathematical Functions, String Functions, Predefined Functions
- names used by Data Types
- File, FileName, Tag, Concealed
OLD Special Constants - to be removed in future builds
The following constants can still be used in SysCAD up to Build139, if the Old135Format tickbox is checked in the General Controller: 
However, they will be removed in future updates. Please consider changing these to Trigger Subroutines as soon as possible.
Special variable
Note: The following are legacy predefined constants that are scheduled for deprecation in the next major releases. To ensure continued compatibility, it is recommended to transition to the newer function.
| Type | Legacy Predefined Constant | Predefined Value | Recommended Replacement |
|---|---|---|---|
| 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. |
StopSolver() see Predefined functions.
|
| BIT | PauseSimulation | If this is set to 1 (true) then the PGM pauses the SysCAD run. | PauseSolver() see Predefined functions.
|
| 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 |