Guardian Programmer's Guide

Table Of Contents
Using DEFINEs
Guardian Programmer’s Guide 421922-014
7 - 25
Using DEFINEs: An Example
!-----------------------------------------------------------
! Procedure to prompt the user for a DEFINE attribute and
! call DEFINESETATTR if the user provides the attribute.
!-----------------------------------------------------------
PROC DEFINE^ATTR(ATTR^NAME,VALUES^LIST,VALUES^LEN);
STRING .ATTR^NAME;
STRING .VALUES^LIST;
INT VALUES^LEN;
BEGIN
INT .DEFAULT^NAMES[0:7] := "$APPLS PROGS ";
INT COUNT^READ;
INT ERROR;
! Obtain a value for the attribute from the user:
DO^AGAIN:
PRINT^BLANK;
PRINT^STR
("Enter a value for the attribute " & ATTR^NAME FOR 16);
PRINT^STR
("Possible values are: " & VALUES^LIST FOR VALUES^LEN);
PRINT^BLANK;
SBUFFER ':=' "Choice: " ->@S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
IF COUNT^READ <> 0 THEN
BEGIN
ERROR := DEFINESETATTR(ATTR^NAME,SBUFFER,COUNT^READ,
DEFAULT^NAMES);
IF ERROR <> 0 THEN
BEGIN
CALL DEFINE^ERRORS(ERROR);
GOTO DO^AGAIN;
END;
END;
END;