Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 78
Using the SIO Procedures: An Example
!------------------------------------------------------------
! Procedure to read records from the data file and display
! them on the terminal. Additional records are prompted for.
!------------------------------------------------------------
PROC READ^RECORDS;
BEGIN
INT ERROR;
INT COUNT^READ;
! Open the output file for reading:
CALL OPEN^OUTPUT(READ^ACCESS);
! Loop until user declines to read another record:
DO
BEGIN
PRINT^BLANK;
! Read the next record from the disk file:
ERROR := READ^FILE(OUTFILE,BUFFER,COUNT^READ,
!prompt^count!,
BUFSIZE);
IF ERROR = 1 THEN
BEGIN
! Inform user of end-of-file and then return:
SBUFFER ':='
"There are no more records in this file. "
-> @S^PTR;
CALL WRITE^FILE(INFILE,BUFFER,@S^PTR '-' @SBUFFER);
CALL CLOSE^FILE(OUTFILE);
RETURN;
END
ELSE
BEGIN
! Write the record to the terminal:
CALL WRITE^FILE(INFILE,BUFFER,COUNT^READ);