LRec: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|
(No difference)
|
Revision as of 13:12, 27 February 2014
LRec(N)
When N is an internal file, LRec internal function returns the number of the last record in the file. When N is an external file, LRec returns the last record or last byte (depending on whether REC= or POS= was used last). When N is a display file, LREC returns the byte size of the file.
When N is not an open internal file handle LRec will return 0 or -1. If N=0 then LRec(N) will return 0. If N is greater than zero but is not an open file handle, LRec will return -1.
Comments and Examples
Here are three quick steps to determine how many records are in an internal file:
00010 OPEN #1:"name=filename",I,I,S 00020 PRINT LREC(1) 00030 CLOSE #1:
As long as there are no deleted records, the number printed by PRINT LREC(1) is the total number of records in file 1.
Related Functions
For additional information about files, see the following functions:
Technical Considerations
- If any space in the file is occupied by records marked for deletion by the DELETE statement, these records will still appear in the total from LREC(N) even though they will not be processed by reading the file sequentially.
- If file N is not open, LREC(N) will return -1.
- For external files, LREC(N) can return either a record number or a byte number, depending on whether the last I/O statement used a REC= clause (the default mode) or a POS= clause (to position to a specified byte number).
- The use of LREC within an I/O statement is strongly discouraged, especially on multi-user systems. See the Multi-user Programming chapter for additional information.