Guardian Programmer's Guide

Table Of Contents
Using DEFINEs
Guardian Programmer’s Guide 421922-014
7 - 17
Using DEFINEs: An Example
The following example uses DEFINESAVEWORK2 to save the attribute values stored
in the current working set. This procedure copies the attributes in the working set to
the background set:
ERROR := DEFINESAVEWORK2;
IF ERROR <> 0 THEN ...
Any attributes that were stored in the background set are destroyed.
The next example restores the background set into the working set using the
DEFINERESTOREWORK2 procedure:
ERROR := DEFINERESTOREWORK2;
IF ERROR <> 0 THEN ...
Note that there is actually a third way of saving and restoring a working set that uses a
buffer instead of a background working set. This method uses the DEFINESAVE and
DEFINERESTORE procedures as already described.
Using DEFINEs: An Example
The sample program shown in this subsection allows the user to create DEFINEs
interactively before starting a process that uses the DEFINEs.
This program first prompts the user for the CLASS of the DEFINE that the user needs
to create. The CREATE^DEFINES procedure then calls a procedure that depends on
the DEFINE CLASS. For example, if the user selected CLASS TAPE, then the
SET^TAPE procedure gets called. This procedure then prompts the user for a value
for each of the DEFINE attributes that pertain to the selected type.
When the user has responded to each possible attribute, control returns to the
CREATE^DEFINES procedure, which calls DEFINEVALIDATEWORK to check that the
working set is consistent before prompting the user for a DEFINE name. When the
user has entered a valid DEFINE name, the CREATE^DEFINES procedure creates the
DEFINE.
Finally, control returns to the MAIN procedure, which prompts the user to create
another DEFINE. When the user declines to create any more DEFINEs, the MAIN
procedure prompts the user for the name of the program file to execute and then
executes the program.
This sample program allows the user to create the following classes of DEFINEs:
CLASS MAP DEFINEs
CLASS SEARCH DEFINEs
CLASS TAPE DEFINEs
CLASS SPOOL DEFINEs
CLASS SORT DEFINEs
CLASS SUBSORT DEFINEs