From BR Wiki
(Redirected from Krec)
Jump to: navigation, search

The KRec internal function:

  1. returns the number of the last accessed key for indexed files
  2. 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:

  1. A Rec=(anchor record) is processed.
  2. An anchor record is read.
  3. An anchor record is written or deleted.

Restore REC=(non-anchor)sets KRec to zero. KRec remains otherwise unaffected during Read and Write statement processing.

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.

Related Functions

For additional information about files, see the following functions: