LRec: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved LRec to LREC)
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
LRec(N)
LREC(<file handle>)


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 the file referred to is an internal file, '''LRec''' [[internal function]] returns the number of the last record in the file. When it's an external file, LRec returns the last record or last byte (depending on whether REC= or POS= was used last). When it's 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.
When the file is not an open internal file handle LRec will return 0 or -1.  If the file handle is equal to, then LRec will return 0.  If it's greater than zero but is not an open file handle, LRec will return -1.


====Comments and Examples====
====Comments and Examples====
Here are three quick steps to determine how many records are in an internal file from [[immediate mode]] (although this could also be a program).


  OPEN #1:"name=filename",I,I,S
Here are three quick steps to determine how many records are in an internal file:
  PRINT LREC(1)
 
  CLOSE #1:
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.
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====
====Related Functions====
For additional information about files, see the following functions:  
For additional information about files, see the following functions:  
*[[Exists]]
*[[Exists]]
*[[File$]]
*[[File$]]
Line 21: Line 24:
*[[FreeSp]]
*[[FreeSp]]
*[[KLn]]
*[[KLn]]
*[[KPSI]]  
*[[KPS]]  
*[[KRec]]
*[[KRec]]
*[[Rec]]  
*[[Rec]]  
Line 27: Line 30:


====Technical Considerations====
====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 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.
# If file N is not open, LREC(N) will return -1.

Latest revision as of 17:31, 22 May 2014

LREC(<file handle>)

When the file referred to is an internal file, LRec internal function returns the number of the last record in the file. When it's an external file, LRec returns the last record or last byte (depending on whether REC= or POS= was used last). When it's a display file, LREC returns the byte size of the file.

When the file is not an open internal file handle LRec will return 0 or -1. If the file handle is equal to, then LRec will return 0. If it's 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

  1. 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.
  2. If file N is not open, LREC(N) will return -1.
  3. 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).
  4. 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.