Predefined Functions
Navigation: PGM SITEMAP
Defining a Class | Defining a Function | Mathematical Functions | Defining a Subroutine | Tag Functions |
---|---|---|---|---|
Predefined Classes | Predefined Functions | String Functions | Trigger Subroutines | Example PGM Files |
Related Links: Defining a Function
Contents
Predefined Functions
The predefined functions available in SysCAD are listed in the Table below. These do not include functions written for predefined classes. For information on those functions, please refer to the Predefined Classes section for the appropriate links.
Notes:
- All Function names are NOT case sensitive.
- "String" or "Message" used in the following functions refer to "A string" or "a variable of the STRING type".
Function | Syntax | Description | Examples | |
Tag Related FunctionsThe Tag functions are used to Fetch/Set Values from/To SysCAD Project. See Tag Functions | ||||
= [ ] | variable = ["FullTag"] variable = [StringVariable] |
This function gets a tag from SysCAD and returns the value of the parameter. This format can be used in place of GetTag(), GetDynTag() and GetDynStrTag() | See GetTag Functions for Full Description and Examples. | |
GetTag() | variable = GetTag("Full SysCAD Tag") | The GetTag function returns the value of the parameter in numerical type. | See GetTag Functions for Full Description and Examples. | |
GetDynTag() | variable = GetDynTag("String") | The GetDynTag function returns the value of the parameter in numerical type, referred to by the tag contained in string | SeeGetTag Functions for Full Description and Examples. | |
GetDynStrTag() | String Variable = GetDynStrTag("String") | The GetDynStrTag function returns the Tag name of the parameter, referred to by the tag contained in string. | See GetTag Functions for Full Description and Examples. | |
[ ] = | ["FullTag"] = variable [StringVariable] = variable [Str "FullTag"] = StringVariable |
This function assigns the value to the parameter. This format can be used in place of SetTag(), SetDynTag() and SetDynStrTag() | See SetTag Functions for Full Description and Examples. | |
SetTag() | SetTag("Full SysCAD Tag", value) | The SetTag function assigns the value to the parameter, referred to by the tag contained in Full SysCAD Tag. | See SetTag Functions for Full Description and Examples. | |
SetDynTag() | SetDynTag(string, value) or SetDynTag("Full SysCAD Tag", value) |
The SetDynTag function assigns the value to the parameter, referred to by the tag contained in string or Full SysCAD Tag. | See SetTag Functions for Full Description and Examples. | |
SetDynStrTag() | SetDynStrTag(String, String2) | The SetDynStrTag function assigns a String2 to String. | See SetTag Functions for Full Description and Examples. | |
DynTagExists() | variable = DynTagExists("String") | The DynTagExists function returns True if the SysCAD tag represented by the string exists, otherwise it returns False. | See DynTagExists for Full Description and an Example. | |
Conditional FunctionsThe Conditional Functions are used to evaluate the condition of the project, based on the result, set a value or command to the project. See Conditional Functions | ||||
If() Elseif() Else Endif |
if ( expression1 ) statements1 elseif (expression2) statements2 else statementsN endif |
Elseif and Else expressions are optional. | See If Statement for Full Description and Examples | |
IIf() | variable = IIf(expression, truePart, falsePart) | The IIf function is a two part if() statement, based on the condition of the expression, the True or False value is returned. | See IIf for Full Description and Examples. Recovery = iif(Feed==0, 0, Product/Feed) | |
While() EndWhile |
While ( expression1 ) statements endWhile |
While the expression is true, the statements will be executed. When writing the While loop, ensure the loop can end, else the solver will be "stuck" inside the loop. | See While Statements for Full Description and Examples | |
Time Related Functions | ||||
DeltaTime() | variable = DeltaTime() | The DeltaTime() function returns the current SysCAD value of Delta Time (simulation step size) in seconds. Note: during the Initialisation step, DeltaTime will equal zero as no time has passed. |
Simulation_Time = Simulation_Time + DeltaTime() This will increment the simulation time every iteration. | |
Time() | variable = Time() | The Time() function, returns the SysCAD time in seconds. | If OnStart
Endif | |
Miscellaneous Functions | ||||
Random() | variable = Random(Number) | The Random function, returns a random number between 0 and Number. If Number is NAN then the function returns an integer between 0 and 32767. Precision is 1 in 32768. | d = Random(100) | |
Species FunctionsSee Species Database Class for additional functions related to species properties. | ||||
MW() | variable = MW("Species/Compound/Element") |
Returns the Molecular Weight of Species, Compound or Element. NOTES:
|
MW_Water = MW("H2O(l)") | |
SpI() | variable = SpI("Species") |
Returns the Species Index in list of project species of the specified species including phase, or -1 if the species is not found.
|
Water_Species_Index = SpI("H2O(l)") See Species Index for usage of species index. | |
User Defined Messages and Errors FunctionsPlease note that the SysCAD log file may be enabled or disabled by the user by ticking the Log to file : $Prj\MessageLog.csv tick box on the Message Window Options Tab. By default this option is disabled. If this option is enabled, then SysCAD will create the MessageLog.csv file in the project. | ||||
LogError() | LogError(message) | The LogError function displays the supplied message in the SysCAD message window and logs it to the log file. If the sound is enabled in SysCAD a beep will be sounded. | LogError("Temperature out of Range") | |
ConditionError() | ConditionError(Index, Boolean expression, message) | Index - valid range from 0 to 7, that is, only 8 error messages can be reported per PGM/General Controller. If the Boolean expression is true, then the message specified is displayed in the Condition part of the Message Window. If the sound is enabled in SysCAD a beep will be sounded. |
ConditionError(0, ReactorT>250, "Temperature Out of Range") | |
LogNote() | LogNote(message) | The LogNote function displays the supplied message in the SysCAD message window and logs it to the log file. If the sound is enabled in SysCAD a beep will be sounded. | LogNote("Solids Density Approaches Limit") | |
ConditionNote() | ConditionNote(Index, Boolean expression, message) | Index - valid range from 0 to 7, that is, only 8 error messages can be reported per PGM/General Controller. If the Boolean expression is true, then the message specified is displayed in the Condition part of the Message Window. If the sound is enabled in SysCAD a beep will be sounded. |
ConditionNote(0, ReactorT<150, "Temperature Low, check conditions") | |
MsgBox() | MsgBox(message) | The MsgBox function displays the supplied message in the SysCAD message window and logs it to the log file in exactly the same way as LogNote. | MsgBox("Temperature Low, check operating conditions") | |
Beep() | Beep() | The Beep function calls the MS Windows MessageBeep function playing a simple beep. Note that this is asynchronous and queues the beep to be played when the application is idle. Behaviour of the beep() function will depend on number of calls to Beep(), CPU utilisation, as well as OS & sound card settings. NOTE: If a value is defined within the function, it is ignored. |
Beep() | |
Sound() |
Sound(Freq, Duration) | The Sound function allows the user to set:
Warning: Use with caution as Duration uses CPU time, using sound with long duration every iteration will slow down the solve time! |
Sound(2000, 10) | |
Variable Status KeywordsSee Also Variable Status and Conversion Functions and Variable Declaration, Defining a Class | ||||
Watch | Watch Class instance Watch Class instance.data Member |
The Watch Keyword allows user to keep track of Class instance or data members. | Noise FeedVariation ;Defining a Noise Class Instance Watch FeedVariation.GetVal See Also Watch for Full description and Examples. | |
ExcludeWatch | ExcludeWatch UserClass[index] | Use ExcludeWatch to hide a class instance display on the access window | ExcludeWatch Heater[0] See Also ExcludeWatch for Full description and Examples. | |
SetConcealed OR SetConcealedState |
SetConcealedState(Variable, bit value) | Use SetConcealedState to set a variable to be hidden from the access window, the hidden variable can be viewed when the ShowConcealed button is pressed on the PGM access window. | See SetConcealedState for Full description and Examples. | |
Conversion FunctionsSee Also Variable Status and Conversion Functions and Variable declaration | ||||
Cnv() | variable = Cnv(variable1, unit) | The Cnv function converts variable1 to the conversion units specified by unit and returns the result. | See See Cnv for Full description and Examples. | |
CnvVal() | variable = CnvVal(variable1, family, unit, ReqdUnit) | The CnvVal function converts variable1 from the conversion units specified by unit to the conversion units specified by ReqdUnit for the specified conversion family and returns the result. | See See CnvVal for Full description and Examples. | |
CnvInfo() | CnvInfo(variable, family, unit) | The CnvInfo function allows conversions (engineering units) to be assigned to a variable. | See See CnvInfo for Full description and Examples. |