The program in Figure 90 uses a selector adjunct to control an error
message field. The output of the program is the same as for MAPEX01, as
shown in Figure 83 in topic 15.2.1.
Although their output is similar, the maps used by the two programs
differ. In addition to having a selector adjunct, the map used by MAPEX05
has the message text as default data in the message field, whereas the one
used by MAPEX01 has blanks.
The selector adjunct is declared at A . The complete ADS is cleared at
B . The selector adjunct for the message field is set to 1 at C . This
value means that the write-type MSPUT call, D , updates the field with
data from the ADS. Initially, then, all the fields, including the message
field, are blank.
If the end user of the program makes an error, the message field selector
adjunct is reset to 2 at E . This value means that the MSPUT, D ,
updates the message field with default data. The default data is the
error message, as defined to GDDM-IMD when the map was created.
MAPEX05: PROC OPTIONS (MAIN);
DCL 1 CUSTINV, /* Included ADS */
10 MESSAGE_SEL CHAR(1), A
10 MESSAGE CHAR(78),
10 CUSTNO CHAR(5),
10 INVNO CHAR(4),
ORDER1_ASLENGTH FIXED BIN(31,0) STATIC
INIT(88);
DCL (ATTYPE,ATVAL,COUNT) FIXED BIN(31); /* ASREAD arguments*/
DCL WRITE FIXED BIN(31) INIT(0); /* MSPUT write operation */
DCL VALID BIT(1) INIT('1'B); /* on until invalid data found*/
CALL FSINIT; /* Initialize GDDM. */
CUSTINV = ''; /* Clear the ADS, so that map-*/ B
/* defined values are taken. */
MESSAGE_SEL = '1'; /* Set message selector to */ C
/* issue blank message. */
CALL MSPCRT(1, /* Create page. */
-1, /* Use mapgroup-defined page */
-1, /* depth and width */
'ACME00D6'); /* for mapgroup 'ACME00D6'. */
CALL MSDFLD(1, /* Map an area of page, */
-1, /* using the map-defined row */
-1, /* and column positions */
'ORDER1'); /* and map ORDER1. */
LOOP:
CALL MSPUT(1, /* Put data into map on page, */ D
WRITE, /* with write operation, */
ORDER1_ASLENGTH, /* specifying the ADS length, */
CUSTINV); /* and the data length. */
CALL ASREAD(ATTYPE, /* Output the current page, & */
ATVAL, /* wait for end-user input. */
COUNT);
IF ATTYPE=1 & (ATVAL=3 | ATVAL=15) /*End user pressed end key?*/
THEN GO TO FIN;
IF COUNT > 0 THEN DO; /* Data entered, so check it. */
CALL MSGET(1,0, /* Get data from map */
ORDER1_ASLENGTH, /* into the ADS. */
CUSTINV);
IF VERIFY(CUSTNO,'0123456789') = 0 /* Are CUSTNO and */
& VERIFY(INVNO,'0123456789') = 0 /* INVNO numeric? */
THEN DO;
/* . */ /* Process CUSTNO and INVNO */
/* . */
/* . */
MESSAGE = ' '; /* Clear any existing message */
END;
ELSE VALID = '0'B; /* Indicate error. */
END;
ELSE VALID = '0'B; /* No data entered, so */
/* indicate error. */
IF VALID THEN DO; /* Error found, so redisplay */
VALID = '1'B; /* the map. */
MESSAGE_SEL = '2'; /* Set selector, so that map */ E
END; /* message appears */
GO TO LOOP;
FIN:
CALL FSTERM; /* Terminate GDDM */
%INCLUDE ADMUPINA; /* GDDM entry declarations */
%INCLUDE ADMUPINF;
%INCLUDE ADMUPINM;
END MAPEX05;
Figure 90. Listing of MAPEX05 source code
|