Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 95
Using Alternate Keys With a Relative File
!------------------------------------------------------------
! Procedure for reading records. The user selected function
! "r." The start of the read is selected randomly by record
! number. The user has the option of sequentially reading
! subsequent messages.
!------------------------------------------------------------
PROC READ^RECORD;
BEGIN
LITERAL APPROX = 0;
INT KEY^SPEC;
INT COUNT^READ;
INT STATUS;
INT ERROR;
! Prompt the user to select a record by entering a date:
CALL GET^DATE;
! Position the current-record and next-record pointers to
! the selected record:
KEY^SPEC ':=' "DA";
CALL KEYPOSITION(LOGNUM,SBUFFER,KEY^SPEC,
!length^word!,
APPROX);
IF <> THEN CALL FILE^ERRORS(LOGNUM);
! Loop, reading and displaying records, until the user
! declines to read the next record (any response other than
! "y"):
DO BEGIN
PRINT^BLANK;
! Read a record from the log file. If the end of file is
! reached, return control to the LOGGER procedure:
CALL READX(LOGNUM,RECORD,BUFSIZE,COUNT^READ);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(LOGNUM,ERROR);
IF ERROR = 1 THEN
BEGIN
PRINT^STR("No such record");
RETURN;
END;
CALL FILE^ERRORS(LOGNUM);
END;