Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 64
Key-Sequenced File Programming Example
!------------------------------------------------------------
! Procedure for inserting a record. The user selected
! function "i." The user is prompted to enter the new record.
! The procedure inserts the new record in the appropriate
! place in the file.
!------------------------------------------------------------
PROC INSERT^RECORD;
BEGIN
INT ERROR;
PRINT^BLANK;
! Prompt the user for the new record:
CALL ENTER^RECORD(NEW);
! Write the new record to the file:
CALL WRITEX(PARTFILE^NUM,PART^RECORD,$LEN(PART^RECORD));
IF <> THEN
BEGIN
CALL FILE_GETINFO_(PARTFILE^NUM,ERROR);
IF ERROR = 10 THEN
BEGIN
PRINT^BLANK;
PRINT^STR
("There is already a record with that " &
"part number.");
PRINT^STR("Your new one was not entered.");
END ELSE BEGIN
CALL FILE^ERRORS(PARTFILE^NUM);
END;
END;
END;
!------------------------------------------------------------
! Procedure to exit the program.
!------------------------------------------------------------
PROC EXIT^PROGRAM;
BEGIN
CALL PROCESS_STOP_;
END;