Data Types

From SysCAD Documentation
Jump to: navigation, search

Navigation: PGMs

PGM Syntax Data Types Declaring Variables Predefined Variables Labels

Summary Table of Data Types

The variable types supported by the PGM are shown below. See also Variable declaration.

Type Name Value Type Range of Values Displayed As Notes
Real Numbers
REAL Real -1.0 E308 to 1.0 E308 Value with decimal points, or * if NAN Use IsNAN function to test for NAN
DOUBLE Real -1.0 E308 to 1.0 E308 Value with decimal points, or * if NAN Use IsNAN function to test for NAN
Integers
INTEGER Integer -2147483648 to 2147483647 Integer
LONG Integer -2147483648 to 2147483647 Integer
BYTE Integer 0 to 255 Integer
Enum Integer Usually starts at 0 Creates a list of integer constants. Only available in SysCAD 9.3
DropList Integer Usually starts at 0 A drop down list, each with an associated integer value Only available in SysCAD 9.3
EnumDropList Integer Usually starts at 0 A drop down list of integer constants. Only available in SysCAD 9.3
Boolean Numbers
BIT Boolean FALSE = 0; TRUE <> 0 0 (False); 1 (True)
CheckBox Boolean FALSE = 0; TRUE <> 0 Tickbox
Alphanumeric Values, or Strings
STRING String ASCII Character Set; Words (unlimited length)
STR String ASCII Character Set; Words (unlimited length)
MEMO String ASCII Character Set; Words (unlimited length) Scrolls onto multiple lines as required


Notes:

  1. Variable names must be alphanumeric and uniquely declared within their current scope.
  2. A variable name can not include a '.' (dot) as part of the name.
  3. The PGM language, including variable naming, is NOT case sensitive.
  4. Only variables of type Double or Real can have a value of NAN (Not a Number) shown as a '*' on the Access window. Use IsNAN function to test for NAN.
  5. When a value or variable is assigned to another variable, it is ranged within the new variable type's range, as illustrated in the examples below.

Examples (showing ranging based on Data Type)

INTEGER  w
BIT      i
BYTE     z

z = 1035    ;z = 255         maximum value of Byte type is 255.
z = -2.3    ;z = 0           minimum value of Byte type is 0.
z = 5.6     ;z = 5           byte can only be integer, it takes the first digit
w = 1.3e12  ;w = 2147483647  maximum value of Long type
w = NAN     ;w = -2147483648 not a number, assigned with the minimum value of type
w = 335.4   ;w = 335         INTEGER type are integers only.
z = w       ;z = 255         limited by the maximum value of byte type.
i = 0.1     ;i = 1 (true)    Bit is true if i ≠ 0
i = 12      ;i = 1 (true)    Bit is true if i ≠ 0
i = -3      ;i = 1 (true)    Bit is true if i ≠ 0
i = 0.0     ;i = 0 (false)   Bit is false if i = 0

User Defined Constants using the Const Keyword

Syntax:

Const TYPE variable = value OR
Const TYPE variable = Predefined Molecular Weight Function

The Const keyword ensures that the value assigned to the variable will remain unchanged (i.e. it becomes a read only variable). See also Predefined Constants and Variables.

Examples

Const real OreDensity = 5000
Const real LiquidHTC  = 1.5    ;Numbers cannot be written as a fraction.

Const real MW_NaCl    = MW("NaCl") 
Const real MW_H2SO4   = MW("H2SO4") 

Const integer Auto    = 1
Const long    Manual  = 2

Const bit Running     = 1
Const bit Stopped     = 0

Const String Condition1 = "Mass balanced"
Const String Condition2 = "Mass NOT balanced"

NOTES:

  1. A Constant variable cannot be declared in a Class.
  2. A Constant variable cannot be displayed in the Access window.
  3. In SysCAD 9.3, a Constant variable cannot be a calculation, this includes using numbers in fractions. So while const Real LiquidHTC = 1.5 will work, LiquidHTC = 3/2 will report an error.

Check Box

The user can add a check box to the access window by declaring the variable as type Checkbox. The check box is a toggle between true(1) and false(0).

Integer variables as Enum

The user may declare a number of integer constants using the Enum command. (Enum is derived from Enumerate) This gives the user a convenient method of declaring a group of integer constants.

Note:

  1. The Enum functionality is only available in SysCAD 9.3.
  2. The user cannot display the Enum constants in the Access window.
  3. The declaration cannot occur within a class, but the constants can be used within a class.

Example 1:

Enum Colours{Red, Green, Blue} ;is equivalent to:
;const integer Red  = 0
;const integer Green = 1
;const integer Blue  = 2

Counting is automatic, starting at 0 and incrementing by 1. However, the user may override the automatic values and assign their own values to the variables.

Example 2:

Enum Shapes{Square = 2, Circle = 4, Oval, Triangle = 9} ;is equivalent to:
;const integer Square   = 2
;const integer Circle   = 4
;const integer Oval     = 5
;const integer Triangle = 9

The user may also declare a single variable of type Enum. This is equivalent to declaring the variable as type long or integer.

Example 3:

Enum Sound ;is equivalent to:
;integer Sound

Enum Drop Down List

This is similar to the straight DropList declaration, in that it creates a drop down list in the access window, but the variables are also constant integers. This is best shown in an example:

Example

EnumDropList Options{Acid=2, Basic=4, Neutral}
Options OperatingMode*

This will be displayed in the Access window as follows:

EnumDropList.png

Notes:

  1. The EnumDropList variable type is only available in SysCAD 9.3.
  2. The initial (default) value of the variable is the first item in the list. In the above example OperatingMode will initially be 2 (Acid).
  3. If the variable is set to a value which doesn't match one of the defined options, SysCAD will choose the option which is numerically the closest. In the above example, if OperatingMode is set to 3, SysCAD will reset its value to 2 (Acid).
  4. Each item in the EnumDropList has an integer value.
    • If the user does not set a value, then counting is automatic, starting at 0 and incrementing by 1.
    • However, the user may override the automatic values and assign their own values to the variables, as shown in the above example. In this case, if a variable is NOT assigned a value, then it's value is incremented by 1 from the previous variable.
  5. The definition of the drop list (using EnumDropList) cannot occur within a class, but once defined, it can be used for variables declared within a class.

Drop Down List

The user can add a Drop Down List to the access window by declaring a variable of type DropList. The variable will be of type Integer. This is best shown in an example:

DropList Options{"Acid", "Basic", "Neutral"}
Options OperatingMode*

This will be displayed in the Access window as follows:

DropDownList.png

Notes:

  1. The Drop Down List variable type is only available in SysCAD 9.3.
  2. Each item shown in the Drop Down List has an integer value starting at 0 and incrementing. In the image above, if the user selects 'Acid', then OperatingMode = 0, if 'Basic' is selected, then OperatingMode = 1 and similarly if 'Neutral' is selected, then OperatingMode = 2.
  3. The initial (default) value of the variable is 0, corresponding to Acid, the first item in the list.
  4. If the variable is set to a value which doesn't match one of the defined options, SysCAD will choose the option which is numerically the closest. In the above example, if OperatingMode is set to 4, SysCAD will reset its value to 2 (Neutral).
  5. Please note that 'Acid' is NOT = 0. If the user requires the variables to have a constant integer value, then they must use the declaration 'EnumDropList' shown above.
  6. The definition of the drop list (using DropList) cannot occur within a class, but once defined, it can be used for variables declared within a class.