The KRec internal function:
- returns the number of the last accessed key for indexed files
- returns the number of records accessed since the last NEWPAGE for display files
Note- following NEWPAGE with a semicolon (e.g. NEWPAGE; ) suppresses the zeroing of KREC.
When processing a linked file, KRec is updated with the location of an anchor record only under the following conditions:
- A Rec=(anchor record) is processed.
- An anchor record is read.
- An anchor record is written or deleted.
Comments and Examples
KRec(N) is really two functions under one name. It has one use with display files, and another use with indexed internal files.
When file N is a display file, KRec(N) acts as a line counter for lines output to the file. This feature is especially useful with printers in counting how many lines have already been printed on a page. Also, outputting a NEWPAGE to advance the paper to the top of the next page resets this counter to zero. Print KRec(255) will return the number of lines output to the standard printer file #255 since the last PRINT #255: NEWPAGE was issued.
If file N is an internal file opened for Keyed processing, then KRec(N) returns the number of the last record accessed in the key file. This is different from the last record accessed in the master file, which can be found by the Rec(N) function.
For additional information about files, see the following functions: