Guardian Programmer's Guide

Table Of Contents
Communicating With Printers
Guardian Programmer’s Guide 421922-014
11 - 44
Sample Program for Using a Printer
!------------------------------------------------------------
! Procedure for updating a record. The user selected
! function "u." The user is prompted to enter the part
! number of the record to be updated, then the old contents
! are displayed on the user's terminal before prompting the
! user to enter the updated record.
!------------------------------------------------------------
PROC UPDATE^RECORD;
BEGIN
INT COUNT^READ;
INT ERROR;
STRUCT .SAVE^REC(PART^RECORD);
STRUCT .CHECK^REC(PART^RECORD);
PRINT^BLANK;
! Prompt the user for the part number of the record to be
updated:
PRINT^BLANK;
SBUFFER ':=' "Enter Part Number: " -> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Position exactly to the selected record. First pad the
! key with blanks in case the full length was not entered:
SBUFFER[COUNT^READ] ':=' [PARTSIZE * [" "]];
CALL KEYPOSITION(PARTFILE^NUM,SBUFFER,
!key^specifier!,
!length^word!,
2);
IF <> THEN CALL FILE^ERRORS(PARTFILE^NUM);
! Read the selected record. If no such record exists,
! the procedure informs the user and returns control to
! the main procedure:
CALL READUPDATEX(PARTFILE^NUM,PART^RECORD,
$LEN(PART^RECORD));
IF <> THEN
BEGIN
CALL FILE_GETINFO_(PARTFILE^NUM,ERROR);
IF ERROR = 11 THEN