670 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Appendix C Structured Text Programming
Assignments
Use an assignment to change the value stored within a tag. An assignment has this
syntax:
tag := expression ;
where:
The tag retains the assigned value until another assignment changes the value.
The expression can be simple, such as an immediate value or another tag name, or
the expression can be complex and include several operators and/or functions.
See Expressions
on page 673.
Instruction
(see page 679
)
An instruction is a standalone statement.
An instruction uses parenthesis to contain its operands.
Depending on the instruction, there can be zero, one, or multiple operands.
When executed, an instruction yields one or more values that are part of a data
structure.
Terminate the instruction with a semi colon(;).
Even though their syntax is similar, instructions differ from functions in that
instructions cannot be used in expressions. Functions can be used only in
expressions.
instruction();
instruction(operand);
instruction(operand1, operand2,operand3);
Construct
(see page 680
)
A conditional statement used to trigger structured text code (that is, other
statements).
Terminate the construct with a semi colon (;).
IF...THEN
CASE
FOR...DO
WHILE...DO
REPEAT...UNTIL
EXIT
Comment
(see page 696
)
Text that explains or clarifies what a section of structured text does.
·Use comments to make it easier to interpret the structured
text.
·Comments do not affect the execution of the structured text.
·Comments can appear anywhere in structured text.
//comment
(*start of comment . . . end of comment*)
/*start of comment . . . end of comment*/
Term Definition Examples
Component Description
Tag Represents the tag that is getting the new value
The tag must be a BOOL, SINT, INT, DINT, or REAL
:= Is the assignment symbol
Expression Represents the new value to assign to the tag
If tag is this data type Use this type of expression
BOOL BOOL expression
SINT
INT
DINT
REAL
Numeric expression
; Ends the assignment