11 - 121 11 - 121
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
LEN
Function
LENgth
• Returns the number of characters of a character string.
LEN ( <character string expression> )
Syntax
character string expression
• • • •
Specify the character string for which the number of
characters will be counted.
Examples
A=LEN(A$)
• • • •
Stores the number of characters in character
variable A$ in A.
A B C D E F
A$
A
6
Description
• The LEN function counts and returns the number of characters of the character string
specified by the character string expression.
• The control characters 00h through 1Fh in the character code and spaces are counted.
• The LEN function counts full-byte characters as two half-byte characters. See the KLEN
function is counting full-byte characters as one character.
Example
A B C D
A B C D
@
@
@
@
LEN Function
KLEN Function
8
6
1 2 3 4 5 6 7 8
1 2 3 4
5
6
Program Example
10 ' Checks the number of characters in the character string
20 A$="@@AD51H-BASIC"
:
' Defines the character string
40 PRINT "Number of characters-->";LEN(A$)
50 END
RUN
Number of characters--> 15
OK
REMARK
See the KLEN function and Section 3.13.2.