11 - 364 11 - 364
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
RIGHT$
Function
RIGHT$
• Extracts a character string consisting of the specified number of characters from the right
end of a character string and assigns it to a variable.
RIGHT$(<character string expression>, <numeric expression>)
Syntax
character string expression
• • • •
Specify the character string that is to be processed.
numeric expression
• • • •
Specify the number of characters to be extracted.
A$=RIGHT$(B$, 4)
• • • •
Extracts four characters from the right end of B$ and
assign them to A$.
Examples
B$
A
B
C
D
E
F
G
H
4
3
2
1
E
F
G
H
A$
Description • The RIGHT$ function extracts a character string consisting of the specified number of
characters from the right end of the string and assigns it to a variable.
• <numeric expression> indicates the length of the character string to be extracted.
• If the value of <numeric expression> is 0, a null character string (" ") is returned.
If a value greater than 255 is specified, an "Illegal function call" error occurs.
• If the value of <numeric expression> is equal to or greater than the length in <character
string expression>, the entire <character string expression> is returned.
• If a full-byte character is included in <character string expression>, it is counted as two
characters.
See Section 3.13.1 (5) for details.
Program Example
10 ' This program extracts seven characters from the right end of a character string
20 A$="Sequence program"
:
'Defines a character string
30 B$=RIGHT$(A$,7)
:
'Specifies to extract seven characters from
the right
50 PRINT "Seven characters from the right--->";B$
:
'Displays the extracted character string
60 END
RUN
Seven characters from the right--->program
OK
REMARK
See the LEFT$, MID$ (1) and MID$ (2) functions, and Section 3.13.2.