Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Syntax rules
l The Condition function block evaluates a multi-line expression. The assignment operator
(:=) is not a valid operator.
l The Action block requires the use of the assignment operator (:=). All other operators are
valid in the Action block provided the final evaluation of the expression is an assignment.
l The expression should end with a semi-colon (;). DeltaV software usually adds a semi-
colon for you if one is not there.
l Brackets used in an expression must be paired. Non-paired brackets can cause database
migration errors.
Note
The expression evaluator is stack oriented and allows a maximum of 32 operands and operators. The
use of parentheses to organize the expression minimizes the stack usage. The equations are
evaluated using RPN (Reverse Polish Notation).
Relative Notation
Assignment Statements
The := operator is an operator in DeltaV expressions. This operator allows for the assignment
of calculated values to locations inside and outside of the current block. Examples of the
assignment operator follow:
output := value;
or
or
If you wanted to increment a module-level parameter called SYRUP, the expression might look
like this:
'/SYRUP' := '/SYRUP' + 1;
Note
The assignment operator is not valid in the Condition block. However, the assignment operator is
required in the Action block.
If-Then-Else-End_if Statements
Note
DeltaV software allows you to use ENDIF or END_IF for your convenience. However, structured text
typically requires the use of the keyword END_IF.
It is not always necessary to use the ELSE portion of the statement. For example, if you
wanted to set the parameter CALC block parameter OUT1 to TRUE when the process variable
of PID1 in LIC-549 goes above 75, the expression would look like this:
Note
The CV extension in this example stands for current value. If the choice exists, ST stands for
status.
After you enter an expression, you can validate the expression syntax. The validation process
identifies syntax problems with the expression and any unresolved parameters. The expression
can be saved to the database with syntax errors, but the errors should be corrected before
downloading the expression.
While-Do-End_While
I := 1;
WHILE (I <= 5) DO
'^/PARAM1'[I][1]:= I + .12;
I := I + 1;
END_WHILE;
Note
The indices are outside of the single quotes unless the .CV field is used. The parameter syntax must
be exactly as shown in the example ('^/PARAM1'[I][1]). It is recommended to show all access to the
matrix parameter (an input or output parameter defined as a floating point array type) using two
dimensions where the second is always [1].
The absolute limit of the number of iterations of a WHILE loop is 2000. However, nested
loops, IF statements within loops, and Labels within loops may reduce the limit. If a
WHILE loop reaches the limit, the loop stops, BLOCK_ERR and MSTATUS are set, and the
loop is not executed until the module is re-downloaded.
Exit
This structure prematurely exits the innermost WHILE-DO loop currently being executed. The
EXIT statement can only appear inside the statements of a WHILE_DO loop.
I := 1;
WHILE (I <= 5) DO
'^/PARAM1'[I][1]:= I + .12;
IF ('^/PARAM1'[I][1] > 5) THEN
EXIT;
END_IF;
I := I + 1;
END_WHILE;
Note
This command is only available in the Calc/Logic and Action function blocks because that is where
the WHILE-DO construction is supported.
GOTO label
The GOTO label structure transfers processing to the statement identified by the specified
label. A label definition is a string followed by a colon (:).
Subtopics:
Syntax for SFC Step Actions
Variables in expressions
I/O references
Matrix Parameter References
Inputs/Outputs of the Calc/Logic Block
External References
Internal References
Dynamic References
Diagnostic Parameters in Expressions
Strings
Operands
Operators
Functions
Reserved keywords
SFC Commands and State Transitions