Intermec PB51 Fingerprint Developer's Guide (old) - Page 65
Closing a File, Verifying the End of a File With EOF, Counting Data Blocks With LOC, Determining
View all Intermec PB51 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 65 highlights
Chapter 4 - Managing Input and Output 10 OPEN "QFILE" FOR OUTPUT AS #1 20 PRINT #1, "Record A,Record B,Record C" 30 CLOSE #1 40 OPEN "QFILE" FOR INPUT AS #1 50 LINE INPUT #1, A$ 60 PRINT A$ 70 CLOSE #1 RUN The printer returns: Record A,Record B,Record C Closing a File When a file is no longer used, it can be closed using a CLOSE statement containing the same reference number as the corresponding OPEN statement. An END statement also closes all open files. Verifying the End of a File With EOF The EOF function is used in connection with INPUT#, LINE INPUT#, or INPUT$ statements to avoid the "Input past end" error condition. When the EOF function encounters the end of a file, it returns the value -1 (TRUE.) If not, it returns the value 0 (FALSE). The next example shows how to use EOF: 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 Counting Data Blocks With LOC LOC 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 number 100 has been read from the file: 10 OPEN "ADDRESSES" FOR INPUT AS #1 200 IF LOC(1)=100 THEN CLOSE #1 ..... ..... Determining File Length With LOF The LOF function returns the length in bytes of an OPENed file. Intermec Fingerprint Developer's Guide 49