Guardian Programmer's Guide

Table Of Contents
Communicating With Printers
Guardian Programmer’s Guide 421922-014
11 - 45
Sample Program for Using a Printer
BEGIN
PRINT^BLANK;
START^LINE;
PUT^STR("No such record");
PRINT^LINE;
RETURN;
END
ELSE CALL FILE^ERRORS(PARTFILE^NUM);
END;
! Save the record for later comparison:
SAVE^REC ':=' PART^RECORD FOR $LEN(PART^RECORD) BYTES;
! Display the record on the terminal:
CALL DISPLAY^RECORD;
! Prompt the user for the updated record:
CALL ENTER^RECORD(OLD);
! Now that the user has entered the changes, reread the
! record and check to see whether someone else changed it
! while the user was responding:
CALL READUPDATELOCKX(PARTFILE^NUM,CHECK^REC,
$LEN(PART^RECORD));
IF <> THEN CALL FILE^ERRORS(PARTFILE^NUM);
IF CHECK^REC <> SAVE^REC FOR $LEN(PART^RECORD) BYTES THEN
BEGIN
CALL UNLOCKREC(PARTFILE^NUM);
PRINT^BLANK;
PRINT^STR("The record was changed by someone else " &
"while you were working on it.");
PRINT^STR("Your change was not made.");
RETURN;
END;
! Write the new record to the file:
CALL WRITEUPDATEUNLOCKX(PARTFILE^NUM,PART^RECORD,
$LEN(PART^RECORD));
IF <> THEN CALL FILE^ERRORS(PARTFILE^NUM);
END;