Intermec PM23c Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43, PM4 - Page 59
Close a File, Verify the End of a File With EOF, Counting Data Blocks with LOC, Determining File
View all Intermec PM23c manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 59 highlights
Chapter 4 - Managing Input and Output Close 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. Verify 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 200 ..... ..... OPEN "ADDRESSES" FOR INPUT AS #1 IF LOC(1)=100 THEN CLOSE #1 Determining File Length with LOF 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 20 ..... ..... OPEN "PRICELIST" AS #5 PRINT LOF(5) Fingerprint Developer's Guide 47