11 - 386 11 - 386
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
STRING$
Function
STRING$
• Returns the specified character for the specified number of times.
STRING$(<numeric expression 1>,<character string expression>)
STRING$(<numeric expression 1>,<numeric expression 2>)
Syntax
numeric expression 1
• • • •
Specify the number of characters to be returned.
character string expression
• • • •
Specify the character to be returned.
numeric expression 2
• • • •
Specify the character code of the character to be
returned.
Assigns five "M" characters to A$.
Examples
A$=STRING$(5,"M")
• • • •
A$
M
M
M
M
M
B$=STRING$(3,&H41)
• • • •
Assigns three characters of the character code $H41
(=A) to B$.
B$
A
A
A
Description
• The STRING$ function returns the specified character for the specified number of times.
• Specify the number of characters in the string obtained in <numeric expression 1>.
• If <character string expression> is used to specify the character, only the first character in
the string is valid. If <numeric expression 2> is used to specify the character, it indicates
that the character code is to be repeated. The allowable specification range of the value is
from 0 to 255. If a value greater than 255 is specified, an "Illegal function call" error occurs.
• It is not allowed to specify a full-byte character in <character string expression> or
<numeric expression 2>. If it is specified, the operation cannot be performed normally.
Program Example
10 ' Display a number of "*" according to the value of the variable A
20 FOR I=0 TO 5
:
' Repeats from I=0 to 5
30 A=2^I
:
' Calculates the value of A
50 A$=STRING$(A,"*")
:
' Assigns the number of "*" obtained in the
calculation
60 PRINT A$
:
' Displays the result
70 NEXT I
80 END
RUN
*
**
****
********
****************
********************************
OK