11 - 40 11 - 40
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
CVI
Function
ConVert to Integer
• Converts a character string, which was converted by the MKI$ function, back to an integer.
CVI ( <character string expression> ) [, S] )
Syntax
character string expression
• • • •
Specify the character string that was converted by
the MKI$ function.
A%=CVI(MI$)
• • • •
Converts the character string (MI$), which was
converted by the MKI$ function, back to the original
integer and assigns it to A%.
Examples
B%=CVI(MI$, S)
• • • •
After replacing the contents of the character string
MI$, converts it back to the original integer and
assigns it to B%.
Description
• The CVI function converts the character string, which was converted by the MKI$ function,
back to the original numeric value.
• Since all the data, which is written into the random access file, has to be a character string,
an integer is converted into a 2-byte character string by the MKI$ function before written
into a file. Conversely, the 2-byte character string has to be converted back to the original
integer when this data is read from the file and to treat as an integer. The CVI function is
used for this purpose.
• The CVI function can convert only the character string, which was converted by the MKI$
function, into an integer. If other character stings are specified in <character string
expression>, normal data will not be returned or an "Illegal function call" error occurs.
• The data, which was converted to a character string by the MKI$ function, can be used for
the data communication in addition to writing to a random access file.
• When the [, S] option is specified, the character string subject to the conversion is
rearranged as follows, then converted it into an integer.
1)
2)
2)
Original character string
L
H
1)
Converts to an
integer.
%
REMARK
See the MKI$ function.