Chapter 8. Structured Text (ST) Programming
368
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
8.2
Statement Types
The Structured Text statements, which specify the actual program execution, consist of the following
types, which are described in more detail on the following pages.
Statement Type Description
Example
Assignment
Sets an object to a specified value.
A := 1; B := A; C := A + B;
CASE
Provides for the conditional execution of a set of
statements.
CASE A OF
1,2 : C := 3;
3: C := 4;
4..5: C := 5;
ELSE
C := 0;
END_CASE;
COMMENT
Places a text explanation in the program. Ignored by
the ST compiler.
(* This is a block comment *)
‘ This is a line comment
// This is a line comment //
Function call
Calls a function for execution.
FbInst(IN1 := 1, OUT1 => A);
RETURN
Causes the program to return from a subroutine.
The return statement provides an early exit from a
block.
RETURN;
EXIT
Terminates iterations before the terminal condition
becomes TRUE (1).
EXIT;
IF
Specifies that one or more statements be executed
conditionally.
IF (A < B) THEN
C := 4;
ELSIF (A = B) THEN
C:= 5;
ELSE
C := 6
END_IF;
FOR … DO
Executes a statement sequence repeatedly based
on the value of a control symbol.
FOR I := 1 TO 100 BY 2 DO
IF (Var1
–
I) = 40 THEN
Key := I;
EXIT;
END_IF;
END_FOR;
WHILE
Indicates that a statement sequence be executed
repeatedly until a Boolean expression evaluates to
FALSE (0).
WHILE J <= 100 DO
J := J + 2;
END_WHILE;
REPEAT
Indicates that a statement sequence be executed
repeatedly until a Boolean expression evaluates to
TRUE (1).
REPEAT
J := J + 2;
UNTIL J >= 100
END_REPEAT;
ARG_PRESENT
Determines whether a parameter value was
present when the function block instance of the
parameter was invoked. For example, a parameter
can be optional (pass by value).
ARG_PRES (IN :=In1, Q:>Out1,
ENO:>Out2);
Empty Statement
;
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...