Mitsubishi QD51 Programming Manual page 319

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
MKS$
Function
• Converts a single-precision type numeric value into a character string.
MKS$ ( <single precision expression> [, S] )
Syntax
single precision expression
B$=MKS$(3. 14159)
Examples
• The MKS$ function converts a single-precision numeric value to a 4-byte character string.
Description
• 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
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.
11 - 149
MaKe Single $
• • • •
• • • •
LSET B$=A$
B$ P U U
LET C$=B$
C$= "PUU
B!=CVS(C$)
B!=1.66667
(Correct)
Converts into
character string.
!
REMARK
See the MKD$, MKI$, CVD, CVI, and CVS functions.
Specify the single precision expression to be
converted into a character string.
Converts into a 4-byte character string and stores in
B$.
OPEN "
:
FIELD #1, 10 AS B$
A!=1.66667
A$=MKS$(A!)
Write
File
Read
"
1)
2)
3)
4)
MELSEC-Q
" AS #1
Write
B$
Read
C$= "
B!=7.8948E-30
(Incorrect)
4)
L
Lower word
3)
H
2)
L
Higher word
1)
H
RSET B$=A$
P U U
LET C$=B$
PUU
"
B!=CVS(C$)
11 - 149

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents