No Warning If GET or SEEK Past End of Random File; Use EOF(n) (41043)
The information in this article applies to:
- Microsoft QuickBASIC 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBASIC 4.5
- Microsoft Basic Professional Development System for MS-DOS 7.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
This article was previously published under Q41043 SUMMARY
When reading a random access file with the GET statement, if you GET
or SEEK beyond the number of existing records, then no "END OF FILE"
error occurs. The records that GET reads after the end of a random
file are simply blank or set to zero. To avoid this behavior, you must
do either of the following:
- Test the value (true or false) of the EOF(n) function after every
GET or SEEK statement to determine if you have reached the end of
the random access file.
OR
- Calculate the number of records in the random access file by
dividing the number of bytes returned from the LOF(n) function by
the length (in bytes) of each record. You can then design your
program to GET or SEEK up to, but not greater than, the number
of records in the file.
Modification Type: | Minor | Last Reviewed: | 8/16/2005 |
---|
Keywords: | KB41043 kbAudDeveloper |
---|
|