Guardian Programmer's Guide

Table Of Contents
Using DEFINEs
Guardian Programmer’s Guide 421922-014
7 - 40
Using DEFINEs: An Example
!------------------------------------------------------------
! This is the main procedure. It calls the INIT procedure to
! initialize, then it goes into a loop calling GET^COMMAND
! to get the next user request and calling the procedure
! to carry out that request.
!------------------------------------------------------------
PROC STARTER MAIN;
BEGIN
STRING CMD;
INT COUNT^READ;
INT ERROR;
CALL INIT;
! Prompt user to request DEFINEs:
SBUFFER ':=' "Do You Want to Set up DEFINEs? " -> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,
@S^PTR '-' @SBUFFER,BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Call CREATE^DEFINES if the user responds 'y':
IF SBUFFER[0] = "y" OR SBUFFER[0] = "Y" THEN
CALL CREATE^DEFINES;
! Prompt the user for the program file name to execute:
PRINT^BLANK;
SBUFFER ':=' "Please enter program file name: "
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,
@S^PTR '-' @SBUFFER,BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Execute the program:
ERROR := PROCESS_CREATE_(SBUFFER:COUNT^READ);
IF ERROR <> 0 THEN
BEGIN
PRINT^STR("Unable to start specified program");
CALL PROCESS_STOP_(!process^handle!,
!specifier!,
ABEND);
END;
END;