6-79
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-5 Programming Languages
6
6-5-3 Structured Text Language
ST code consists of one or more statements. One statement is the equivalent of one process. State-
ments are executed from top to bottom, one line at a time, until the process is completed. Statements
are made up of keywords and expressions. A keyword is a symbol or string that expresses assignment
or execution control. An expression is a code that calculates a value from variables, constants, function
return values, and/or a combination of those, along with various operators. A statement represents a
process that completes by itself. Expressions form a statement by using a combination of values and
keywords.
Example of an Assignment Statement:
Example of an IF Construct:
Statement Separators
• Statements must end with a single-byte semicolon (;). Statements are not considered complete
with only a carriage return at the end. This allows you to write long statements across multiple
lines.
• One statement must end with one single-byte semicolon (;). In the following example, the IF con-
struct contains a single assignment statement. Each statement must be ended with a single-byte
semicolon (;).
Comment
• You can write comments in your program to make the code easier to understand.
• Statements written as comments are not executed.
Structure of ST
ST Language Expressions
A:= B + 100 * ABC (10, 20) ; (*Assign A to B + 100 * ABC (10, 20)*)
Assignment
keyword
Expression
Operators
Variables
Constant
Return value of function
Comment
IF D = E + 100 * DEF(10,20) THEN
G := H ;
END_IF ;
IF keyword
IF keyword
Statement
IF keyword
Expression
(*TRUE if D and E+100*DEF(10,20) are equal, otherwise FALSE*)
IF A=B THEN
C := D;
END_IF;
IF construct
Assignment
statement