Publication 1756-RM084F-EN-P - July 2002
6-2 Entering Structured Text Logic
Entering Structured Text
Logic
You enter structured text logic within an STX_ROUTINE component in
an import/export file. Each line of structured text must begin with a
single quote (‘).
Structured text is not case sensitive. Structured text can contain:
For details on these components, see the structured text appendix that
is in both the Logix5000 Controllers General Instructions Reference
Manual, publication 1756-RM003 and in the Logix5000 Controllers
Process Control and Drives Instructions Reference Manual, publication
1756-RM006.
Term: Definition: Examples:
assignment Use an assignment statement to assign values to tags.
The
:=
operator is the assignment operator.
Terminate the assignment with a semi colon “;”.
tag
:=
expression
;
expression An expression is part of a complete assignment or construct statement.
An expression evaluates to a number (numerical expression) or to a true
or false state (BOOL expression).
An expression contains:
tags A named area of the memory where data is stored
(BOOL, SINT,INT,DINT, REAL, string).
value1
immediates A constant value.
4
operators A symbol or mnemonic that specifies an operation
within an expression.
tag1
+
tag2
tag1
>=
value1
functions When executed, a function yields one value. Use
parentheses to contain the operand of a function.
Functions can only be used in expressions.
function
(
tag1
)
instruction 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 “;”.
Instructions cannot be used in expressions.
instruction();
instruction(operand);
instruction(operand1,
operand2,operand3);
construct A conditional statement used to trigger structured text code (i.e, other
statements).
Terminate the construct with a semi colon “;”.
IF...THEN
CASE
FOR...DO
WHILE...DO
REPEAT...UNTIL
EXIT
comment 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
*/