Related Links: General Controller, Model Procedures, Example PGM Files, Frequently Asked Questions, Notepad++ Auto-complete Functions and Keywords
PGM LANGUAGE
|
Introduction |
The built in programing language referred to as a PGM (Programmable Module) is often used to extend the functionality of SysCAD models. It is used by the General Controller Model and can be edited with any text editor, however NotePad++ with colour syntax hi-lighting is recommended. The PGM syntax is similar to other programing languages like VB.
|
Declaring and Managing Variables
|
Data Types
|
- Bit | CheckBox
- Real | Double
- Const
- Byte
- Integer
- Long
- Str | String
- Memo
- Enum
- DropList
- EnumDropList
|
Variable Status
|
- Declared variables can be appended with:
- Read/write enabled *, read only @, concealed @@;
- with Engineering units - eg:("Qm","t/h") and range limits <Min, Max>.
- Examples:
- REAL FeedSolids{i,Range(0,100),Comment("Percent")}
- REAL SolidFeedRate{*,("Qm","t/h"),<<18>>,<10, 20>}
|
Labels
|
- PageLabel()- used to add tabs to the PGM access window,
- TextLabel() - used to add description to the PGM access window
|
PGM Programming and Conventions
|
PGM Syntax
|
- Semicolon(;) marks the comments.
- >>filename loads in another include file.
- Dollar Sign($) or EndFile marks the End of the file.
- SetChangeTagOn and SetChangeTagOff control if Change Tag should apply to the file.
|
Predefined Variables
|
- Pi
- Gc
- Rgc
- StdT
- StdP
- NAN
- SolveMode
- True
- False
- OnStart
- OnInitialise
- OnTerminate
- StopSimulation
- PauseSimulation
- ModelTag
|
Operators
|
|
Trigger Subroutines
|
|
Keywords & Functions
|
SysCAD Tag Functions
|
- SysCAD GetTag Functions
- Variable = ["SysCAD Tag"]
- Variable = GetTag("SysCAD Tag")
- Variable = GetDynTag("SysCAD Tag")
- String = GetDynStrTag("String")
- SysCAD SetTag Functions
- ["SysCAD Tag"] = variable
- SetTag("SysCAD Tag", value)
- SetDynTag("SysCAD Tag", value)
- SetDynStrTag(String, String2)
- Check for valid Tag
- variable = DynTagExists(string)
|
Defining a Function |
- Function, Return, EndFunct
- StrFunction, Return, EndFunct
|
Defining a Subroutine |
|
Predefined Functions
|
- If Statements: If, ElseIf, Else, Endif ; IIf()
- While Statements: While, Endwhile
- Time Keywords: Time(), DeltaTime()
- Miscellaneous Functions: Random()
- Species Functions: MW(), SpI()
- Messages: LogError(), LogNote()
- Conditions: ConditionError(), ConditionNote()
- Message box: MsgBox(), Beep(), Sound()
- Watch Keywords: Watch(), ExcludeWatch()
- Conceal state: SetConcealedState
- Conversions: Cnv(), CnvVal(), CnvInfo()
|
Maths Functions
|
- Sqrt
- Pow
- Exp
- Sin
- Cos
- Tan
- ATan2
- Abs
- IsNAN
- Ln
- Log
- Max
- Min
- Range
- Trunc
- Round
- Roundup
- Mod
- Div
- Erf
|
String Functions
|
- Left
- Right
- Mid
- StrCat/Concatenate
- StrStr
- StrCmp
- StriCmp
- StrLen
- StrUpr
- StrLwr
- AlphaToNum
- IntToStr
- IntStr / IntStr0
- FltToStr
- FltStr
- StrToInt
- StrToFlt
- Trim
- TrimWhiteSpace
- IsAlpha
- IsEmpty
|
Classes
|
Defining a Class |
Syntax: Class, Endclass
|
Species Database Class |
This class gives access to information about species and phases within a project. For example, users can obtain species Density, Saturated Temperature or Pressure, number of solid species in a project, etc.
|
Particle Size Definition Class |
This class gives access to information about the Particle Size Definition (PSD) within a project. For example, users can find the number of Size Intervals in a PSD, the Top and bottom Size, etc.
|
Predefined Classes
|
|
OTHERS
|
Examples
|
|
Frequently Asked Questions |
Some frequently asked questions and answers.
|
PGM Error Codes |
This gives some explanation for the error codes used by SysCAD when reporting problems with PGM file syntax.
|