Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 43
Programming the Requester
! Prompt user to read more records. Return to MAIN
! procedure unless the user types "y" or "Y":
PRINT^BLANK;
SBUFFER ':=' "Do you want to read another record (y/n)? "
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y") THEN RETURN;
! Loop reading and displaying records until user declines
! to read the next record (any response other than "y"):
DO BEGIN
PRINT^BLANK;
! Set REQUEST^FUNCTION to get the next record:
REQUEST.REQUEST^FUNCTION := READ^NEXT;
! Set PART.PART^NUMBER to the part number just read:
REQUEST.PART.PART^NUMBER ':=' PART^RECORD.PART^NUMBER
FOR PARTSIZE;
! Send request to 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));
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 the record on the terminal:
PART^RECORD ':=' REQUEST FOR $LEN(PART^RECORD);
CALL DISPLAY^RECORD;
PRINT^BLANK;