6 - 5 6 - 5
MELSEC-Q
6 I/O Processing of Data Files
When handling numeric data
When writing numeric data into a sequential file, the numeric value is written after
automatically converting into the character data. Also, when reading data from a
sequential file as numeric data, the written character data will be automatically
converted into the numeric values. Therefore, data from a sequential file that is
comprised only with numbers can be treated as character data or numeric data.
Example
Assume
A = 80.5
B = 13.15
• PRINT #n, A;B
[CR] [LF]
.
0
8
5
1
3
1
5
.
Contents of data file
When numeric data is written, spaces will automatically be written similar to the PRINT
instruction for the screen.
For details on controlling spaces, see Section 3.10.
In this case, there is no separator between 80.5 and 13.15, so the contents of the data
file will be treated as one data.
Also, spaces are ignored when using numeric data in BASIC, but since data such as
80.513.15 is not valid as a single number, and an error will be generated.
To treat these as two separate data, a comma is used as follows.
• PRINT #n , A ; " , " ; B
[CR] [LF]
.
0
8
5
1
3
1
,
5
.
Contents of data file
Because BASIC treats commas (,) as separators, the data will be treated as two
separate data.
When reading data from a sequential file, the data will always be read in order starting
from the beginning. When there is no more data to be read, an "INPUT past end" error
will be generated.
The EOF function is used to avoid this error. The EOF function will be "TRUE" when
there is no more data to be read, and this function can be judged by the IF instruction.
EOF
FAL
SE
ERROR
TRUE
EOF
EOF
FAL
SE
Sequential
Data File
EOF Function
INPUT #n, • • •
INPUT #n, • • •
INPUT #n, • • •
INPUT #n, • • •
(0)
(0)
(1)
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...