11 - 122 11 - 122
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
LET
Instruction
LET
• Assigns the value of the expression to a variable.
[LET ] <variable name> = <expression>
variable name
• • • •
Specify numeric variable, character variable, or array
variable.
Syntax
expression
• • • •
Specify numeric expression, character string, array,
or function.
LET A=1
• • • •
Assigns "1" to numeric variable A.
Examples
LET A$=”MITSUBISHI”
• • • •
Assigns character string “MITSUBISHI” to character
string variable A$
Description
• The LET instruction assigns the value of an expression to a variable.
• The LET command may be entirely omitted.
LET A=10
A=10
Example
LET A$=”NAGOYA”
A$=”NAGOYA”
• If the <expression> is a numeric expression, <variable name> must be a numeric variable.
If the <expression> is a character string, the <variable name> must be a character string
variable. If the <expression> and <variable name> do not match, a “Type mismatch error”
will be generated.
• If the <expression> and <variable name> types do not match, the <expression> should be
changed to match with the <variable name> type and then assigned.
Integer type
variable
A%=55.88
PRINT A%
55
Single-precision
type variable
B=.8571428571428571
PRINT B
.857143
Double-precision
type variable
C#=2.04
Example
PRINT C#
2.039999961853027