11 - 149 11 - 149
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
MKS$
Function
MaKe Single $
• Converts a single-precision type numeric value into a character string.
MKS$ ( <single precision expression> [, S] )
Syntax
single precision expression
• • • •
Specify the single precision expression to be
converted into a character string.
Examples
B$=MKS$(3. 14159)
• • • •
Converts into a 4-byte character string and stores in
B$.
Description
• The MKS$ function converts a single-precision numeric value to a 4-byte character string.
• Single-precision numeric values that will be written to the random file buffer using the LSET
or RSET instruction must be converted to a character string with the MKS$ function.
• The data converted into a character string by the MKS$ function can be restored to the
original numeric value only by the CVS function.
• It is recommended to use the LSET instruction when writing data that was converted to a
character string using the MKS$ function to the random file buffer.
If the field length (number of bytes) of each variable specified by the FIELD instruction is
greater than the used field length (number of bytes) of the MKS$ function, the data will not
be correctly converted by the CVS function.
Example
OPEN " : " AS #1
FIELD #1, 10 AS B$
A!=1.66667
A$=MKS$(A!)
B$ P U U
B!=1.66667
B!=CVS(C$)
C$= "PUU "
LSET B$=A$
LET C$=B$
(Correct)
C$= " PUU "
B!=7.8948E-30
B!=CVS(C$)
LET C$=B$
RSET B$=A$
B$
P U U
Write
Write
Read
Read
File
(Incorrect)
The CVS function converts the required number of bytes from the left side of each variable
area specified by the FIELD instruction.
• The data converted to character strings using the MKS$ function may be used for data
communication as well as for writing to the random file buffer.
• When the [,S] option is specified, the single-precision real number will be converted to a
character string and rearranged as follows.
1)
2)
3)
4)
!
4)
3)
2)
1)
Converts into
character string.
L
H
L
H
Lower word
Higher word
REMARK
See the MKD$, MKI$, CVD, CVI, and CVS functions.