<< Click to Display Table of Contents >> Expression Syntax |
What is arithmetic expression syntax?
The expression syntax is the syntax for expressing an expression.
Below is an example of usage.
■ The calculation formula defined in the Expression of the summary action calculation field master
example)
T001 + T002 + T003 / 3 |
syntax
The expression syntax can include values (e.g. T/F, 123, "abc"), operators (e.g. + - / & |), variables (e.g. U01.F01.T01, [CM0]), and functions (e.g. CNumStr).
The format of the arithmetic expression syntax is as follows (Note: For the sake of abstraction, in this manual, variables are expressed as VAR1, VAR2, VAR3, etc.).
■ Syntax 1
Arithmetic Expression
In syntax 1, only the arithmetic expression is written.
example)
VAR1 * 100 VAR2 * VAR3 + 100 CNumStr((VAR1 + VAR2) / 2, 2) |
■ Syntax 2
{Condition expression 1}{Condition value 1}, {Condition expression 2}{Condition value 2}, … ,{default}{ Default value}
Syntax 2 allows you to write a conditional expression and the conditional value when that condition is met. This syntax allows you to perform conditional branching.
The condition expressions are evaluated from left to right, and the value when the condition is met (condition value) becomes the result value. If none of the conditions apply, the default value on the right becomes the result value.
example)
{VAR1}{"ON"},{default}{"OFF"} {VAR1>=80}{"High"},{VAR2>20}{"Normal"},{default}{"Low"} {VAR1>=80}{"#FFFFFF"},{VAR3>20}{"#FF0000"},{default}{"#0000FF"} |
variable
The arithmetic expression syntax is used in a variety of situations, and allows you to specify variables within the arithmetic expression.
What you specify for the variable depends on the function you are writing the syntax for, whether it's a tag path, a field name, or something else.
■ About prohibited characters
Variables used in the arithmetic expression syntax cannot contain the following characters:
1)Do not use the same characters as the operator symbols defined in "Operators" (e.g. +, -, *, /, etc.).
However, you can also use variables by enclosing them in single quotation marks (') as in the example below.
Example)
'U01.F01.TAG-01' //If it contains a "-" sign 'U01!Alive' //If "!" symbol is included 'U01.F01.#SD0000+FIL=LIN:0|1|0|100' // When using the Active tag filter |
2)blank character. Example: "TAG 01"
3)"" double quotation marks and "'" single quotation marks Example: "TAG"02""
4)The first character cannot be a number. Example: "123TAG".
5)The first character of a variable in an arithmetic expression cannot be an underscore.
Example: "_TAG01"
6)Full-width characters. Example: "U01.F01.Pump1" *This does not mean that all full-width characters cannot be used, but since there are cases in which they cannot be used depending on the character code, please try to avoid using full-width characters where possible.
Data Types
The following four types of values can be used in the arithmetic expression syntax:
Data Types |
explanation |
Boolean |
It is a Boolean value (T or F). "T" represents the On state and "F" represents the Off state. |
Number |
It is a number. It can also handle decimal points. |
character |
A string. |
time |
Time (date and time). |
The specifications for each value are the same as SC2 syntax data type.
Operators
The operators that can be used in the calculation expression syntax are as follows:
Operator |
|||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Arithmetic Operators |
|
||||||||||||||||||
Comparison Operators |
|
||||||||||||||||||
Logical Operators |
|
||||||||||||||||||
Bitwise Operators |
|
Calling a function
You can call functions (root methods) from the arithmetic expression syntax. You can use methods that have a "○" specified in the "arithmetic expression syntax" field in the root method list.