Omron NJ-series User Manual page 272

Machine automation controller cpu unit software
Hide thumbs Also See for NJ-series:
Table of Contents

Advertisement

ST Language Statements
 Assignment
Overview:
This statement assigns the right side (i.e., the value of the expression) to the left side (i.e., the vari-
able).
Reserved Words:
:=
Combination of a colon (:) and an equals sign (=)
Statement Structure:
<variable>:=<expression>;
<variable>:=<variable>;
<variable>:=<constant>;
Application:
Use this statement to assign a value to a variable. For example, use it to set initial values or to store
the results of a calculation.
Description:
This statement assigns (or stores) the <expression_value> to the <variable>.
Example:
Example 1: The following statement assigns the result of the expression X+1 to variable A.
A:=X+1;
Example 2: The following statement assigns the value of variable B to variable A.
A:=B;
Example 3: The following statement assigns a value of 10 to variable A.
A:=10;
Precautions:
• Either the source data type must match the destination data type, or the combination of data types
must allow implicit casting. A building error will occur if you do not use this notation.
• If the value that is assigned is STRING data, make the size of the destination STRING variable
larger than that of the source string. Otherwise, an error will occur.
• For STRING variables, assignment is allowed if the size of left-hand variable is greater than the
size of the text string stored in right-hand variable.
Example:
Assignment is allowed in the following case.
• Variable Table:
Variable
name
Var1
Var2
• User Program:
Var2 :='ABC';
NJ-series CPU Unit Software User's Manual (W501)
Data type
Size
STRING
10
STRING
20
6 Programming
6
6-85

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents