Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 42
Programming the Requester
!------------------------------------------------------------
! Procedure for reading records. The user selected function
! "r." The start of the read is selected by approximate key
! positioning. The user has the option of sequentially
! reading subsequent records.
!------------------------------------------------------------
PROC READ^RECORD;
BEGIN
INT COUNT^READ;
INT ERROR;
! Prompt the user for the part number:
PRINT^BLANK;
SBUFFER ':=' "Enter Part Number: " -> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Fill in REQUEST^FUNCTION and part number parts of data
! structure:
REQUEST.REQUEST^FUNCTION := READ^APPROX;
REQUEST.PART.PART^NUMBER ':=' [PARTSIZE*[" "]];
REQUEST.PART.PART^NUMBER ':=' SBUFFER FOR COUNT^READ;
! Request one record from the server.
! If server replies with end-of-file indication,
! return control to the main procedure.
CALL WRITEREADX(SERVER^NUM,REQUEST,$LEN(REQUEST),
$LEN(PART^RECORD),COUNT^READ);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(SERVER^NUM,ERROR);
IF ERROR = 1 THEN
BEGIN
PRINT^STR("No such record");
RETURN;
END;
CALL FILE^ERRORS(SERVER^NUM);
END;
! Display record on terminal:
PART^RECORD ':=' REQUEST FOR $LEN(PART^RECORD);
CALL DISPLAY^RECORD;