Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 80
Using the SIO Procedures: An Example
!------------------------------------------------------------
! Procedure to write a new record to the disk file.
!------------------------------------------------------------
PROC WRITE^RECORDS;
BEGIN
INT READ^OR^WRITE;
INT COUNT^READ;
! Open the output file for writing:
CALL OPEN^OUTPUT(WRITE^ACCESS);
DO BEGIN
PRINT^BLANK;
! Prompt the user to enter a record:
SBUFFER ':=' "Type the New Record: " -> @S^PTR;
CALL READ^FILE(INFILE,BUFFER,COUNT^READ,
@S^PTR '-' @SBUFFER,BUFSIZE);
! Write the record to the disk file:
CALL WRITE^FILE(OUTFILE,BUFFER,COUNT^READ);
! Prompt the user to write another record:
PRINT^BLANK;
SBUFFER ':='
"Do You Wish to Write Another Record (y/n)? "
-> @S^PTR;
CALL READ^FILE(INFILE,BUFFER,COUNT^READ,
@S^PTR '-' @SBUFFER,BUFSIZE);
END
UNTIL NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y");
! Close the output file:
CALL CLOSE^FILE(OUTFILE);
END;