Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 30
Coding the Requester Program
!----------------------------
! Prompt for and process the
! quantity requested
!----------------------------
! Repeat until valid quantity entered:
REPEAT^QTY:
! Prompt for the quantity required:
PRINT^BLANK;
START^LINE;
PUT^STR("Enter Quantity: ");
CALL WRITEREADX(TERM^NUM,SBUFFER,
@S^PTR '-' @SBUFFER,BUFSIZE,COUNT^READ);
! Check that input is numeric:
I := 0;
WHILE I < COUNT^READ DO
BEGIN
IF SBUFFER[I] < "0" OR SBUFFER[I] > "9" THEN
BEGIN
PRINT^BLANK;
PRINT^STR("Quantity must be numeric");
GOTO REPEAT^QTY;
END;
I := I + 1;
END;
! Convert input from a numeric string to a number, and place
! it in the ORDER^REQUEST message:
BASE := 10;
CALL NUMIN(SBUFFER[0],ORDER^REQUEST.QTY^ORDERED,
BASE,STATUS);
! If status indicates an error, print diagnostic and prompt
! again for the quantity:
IF STATUS <> 0 THEN
BEGIN
PRINT^BLANK;
PRINT^STR("Invalid input ");
PRINT^STR("Please enter a valid number ");
GOTO REPEAT^QTY;
END;