Scripting Language

The scripting language implements decision rules, mathematical expressions and provides control over the properties of fields. A script executes a list of statements in sequence.  Statements may either be rules or expressions made up of variables, operators, functions and constants.  

The Architect scripting language also caters for the addition of descriptive comments, which improves the interpretation and maintainability of scripts, particularly in the case where scripts become complex.  

Return to configuring the Script block

In this section you can find out more about:

Variables

There are four types of variables:

  1. Input field variables - All the fields in the input port are available as read-only variables. It is not possible to change the value, time stamp, quality or custom properties of an input field variable.

  2. Output field variables - The script may reference all the fields in the output port. The properties of the output fields may be changed in assignment statements. Output fields may also be used in expressions.

  3. Local variables - Local variables may be used for storage of temporary results. Local variables are introduced in the script where an assignment is made to the variable for the first time. A local variable does not keep it's value from one script execution to the next.

  4. State variables - State variables are similar to local variables. State variables are introduced in the script where an assignment is made to the variable for the first time. State variables differ from local variables in that they do keep their values from one script execution to the next.

    Note : Take care to initialise state variables correctly on the first execute of the script. The 'firstexecute' constant may be used to detect the first execution of the script.

Return to top

Data types

Every variable has a data type. In expressions that include both integer and floating point data types, the integers are converted to floating point type before the calculation is performed. If a floating point or integer variable needs to be converted to a field type variable, the time stamp of the converted variable will be the current execution time stamp and the quality will be set to good.

The basic data types and examples of these are shown below:

Return to top

Field Properties

Input and output variables are field data types. If you assign an input or output field to a local variable, the local variable will also be of field data type. All field variables have the 3 properties as shown below:

To refer to a particular field variable property, follow the variable name with a ‘.’ and the property name.

Example

input1.value := 5

temp.quality := qualitygood

Some fields have custom properties. You access the custom properties in the same way as accessing the normal properties.

Example

R2 := NonLinearOutput.R2 (the R2 value of the Nonlinear model when last trained)

The bits of integer variables may be accessed as booleans using the bit[n] property. The bytes of integer variables may be accessed as integers using the byte[n] property.

Example

if integerInput.bit2 then ...

code.byte2 := 4

The parts of a time variable may be accessed as integers. The figure shows the value of the properties for a time variable with value 2001/01/02 15:10:23.

Example

if now.minute = 5 then ...

The parts of a duration variable may be accessed as double. The part value represents the total duration. The figure shows the value of the properties for a duration variable with value 5::03:10:23.

Example

timediff := a.timestamp - b.timestamp
timediffHours := timediff.hours

Return to top

Expressions

There are two types of expressions available in the scripting language: mathematical expressions and boolean expressions. Mathematical expressions uses the mathematical operators, numeric fields, numeric variables, numeric constants and the mathematical functions.

Example

sinc_x := sin(x) / x

  

Boolean expressions uses the relational operators, logical operators and boolean variables.

Example

tooHot := temperature - 273 > temperatureThreshold

Return to top

Statement types

Follow the links below to learn more about some of the types of statements that may be constructed using the scripting language.  Examples are provided to demonstrate how the scripting language may be used.

>> Assignment statements

>> Conditional rules

Available constants

Press CTRL-SHIFT-C in the script editor to display the list of constants.

Return to top

Available functions

Press CTRL-SHIFT-F in the script editor to display the list of functions that are available.

Return to top

How to add comments

Explanatory notes may be added in the script.  There are two types of comments. Text between /* and */ do not form part of the script and this text is treated as a comment. Text following // until the end of the line is also ignored and is regarded as a comment.  Examples are given below.

Example

 

Return to top


Related topics:

  

CSense 2023- Last updated: June 24,2025