Programming instructions

66
Intermec Fingerprint 6.13 – Programmer's Guide
7. INPUT TO FINGERPRINT, cont'd.
4. Input from a Sequential
File, cont'd.
CLOSE
When a file is no longer used, it can be closed by means of a CLOSE
statement containing the same reference number as the correspond-
ing OPEN statement. An END statement also closes all open files.
A few instructions facilitate the use of files for sequential input:
EOF (End of File)
The EOF function can connection with the statements INPUT#,
LINE INPUT# and INPUT$ to avoid the error condition "Input past
end". When the EOF function encounters the end of a file, it returns
the value -1 (TRUE). If not, it returns the value 0 (FALSE).
Example:
10 DIM A%(10)
20 OPEN "DATA" FOR OUTPUT AS #1
30 FOR I%=1 TO 10
40 PRINT #1, I%*1123
50 NEXT I%
60 CLOSE #1
70 OPEN "DATA" FOR INPUT AS #2
80 I%=0
90 WHILE NOT EOF(2)
100 INPUT #2, A%(I%):PRINT A%(I%)
110 I%=1+1:WEND
120 IF EOF(2) THEN PRINT "End of File"
RUN
LOC (Location)
The LOC function returns the number of 128-byte blocks, that have
been read or written since the file was OPENed.
This example closes the file "ADDRESSES" when record No. 100
has been read from the file:
10 OPEN "ADDRESSES" FOR INPUT AS #1
.....
.....
.....
200 IF LOC(1)=100 THEN CLOSE #1
.....
.....
LOF (Length-of-File)
The LOF function returns the length in bytes of an OPENed file.
The example illustrates how the length of the file "Pricelist" is
returned:
10 OPEN "PRICELIST" AS #5
20 PRINT LOF(5)
.....
.....
Relational Operators
Also see:
Chapter 4.9