GDDM V3R2 Base Application Programming Guide
Previous topic | Next topic | Contents | Index | Contact z/OS | Library | PDF | BOOK


Example of selection with cursor, light pen, and PF key

GDDM V3R2 Base Application Programming Guide
SC33-0867-01



The program in Figure 91 creates a display from which the terminal operator must select one of four options. The format of the map it uses is shown in Figure 92. All the text is constant data.

There are three methods of selection:

  • With one of the four specified PF keys
    
    
  • Positioning the cursor under the selected option and pressing the ENTER key
    
    
  • With the light pen (or CURSR SEL key). The first character of each selectable field is a blank, which means immediate selection with no data.
    
    

The map was designated a cursor receiver on the GDDM-IMD Map Characteristics frame. GDDM-IMD enables you to group similar fields into arrays, using the Field Naming frame of the map editor. This feature has been used for the four option fields in this example. Selector and cursor adjuncts were specified on the Application Data Structure Review frame, and these are shown in the ADS at A and B . An initial position was specified for the cursor, namely, under the one-byte field called DUMMY.

The main loop of the program is executed once each time the operator makes a selection. The first statement of the loop, C , clears the ADS. This removes any message outstanding from a previous iteration, and sets the selector and cursor adjuncts to blank. This means that GDDM uses the map-defined cursor position and the default data for all the option fields.

If the last input was incorrect, the error message is then copied into the ADS.

The MSPUT, D , updates the page with all the changes resulting from C , and with the error message, if this is required. It specifies a write-type operation, so the blank designator characters specified in the map are put into the selectable fields before every execution of the ASREAD. This prevents any problems arising from the operator overtyping these characters.

The SELECT statement, E , discovers which selection method the end user used, by testing the first ASREAD parameter, ATTYPE. If the value 0 is found at F , meaning that the ENTER key was pressed, the group of statements starting at G is executed. These find which of the cursor adjuncts contains a character 1. The program calls a subroutine to perform the requested function, or sets a flag if terminate was requested. If no option was selected, the error flag is set.

If the value 1 for ATTYPE is detected at H , the second ASREAD parameter, called ATVAL, is tested by the group of statements at I , to discover which PF key was pressed.

If the value 2 for ATTYPE is found at I , meaning that the light pen (or CURSR SEL key) was used, the selected field is discovered in the statements at J .

If ATTYPE has some value other than 0, 1, or 2, the end user must have pressed an invalid key, so the error flag is set at K .



MAPEX08: PROC OPTIONS (MAIN);

DCL 1 INITSEL, /* Application Data Structure */

10 MESSAGE_FIELD CHAR(78), 10 DUMMY CHAR(1), 10 OPTION_ARRAY(4), 15 OPTION_SEL CHAR(1), A 15 OPTION_CURSOR CHAR(1), B 15 OPTION CHAR(30), INITSEL_ASLENGTH FIXED BIN(31,0) STATIC INIT(207);

DCL (ATTYPE,ATVAL,COUNT) FIXED BIN(31);/* ASREAD arguments. */ DCL WRITE FIXED BIN(31) INIT(0); /* MSPUT write operation.*/ DCL PROCESS BIT(1) INIT('1'B); /* On until terminate chosen. */ DCL INVALID BIT(1) INIT('0'B); /* On if invalid option chosen*/

CALL FSINIT; /* Initialize GDDM. */

CALL MSPCRT(1, /* Create mapped page 1, */ -1, /* with GDDM-IMD specified */ -1, /* page width and depth, */ 'ACME00D6'); /* for mapgroup ACME00D6. */

CALL MSDFLD(1, /* Format an area of the page,*/ -1, /* at GDDM-IMD specified row */ -1, /* and column position, */ 'INITSEL'); /* using map INITSEL. */

DO WHILE (PROCESS); /* Until end option chosen. */

INITSEL = ''; /* Clear the message field */ C /* adjuncts. */ IF INVALID THEN DO; /* Error noted. */ INVALID = '0'B; MESSAGE_FIELD = 'INVALID SELECTION'; CALL FSALRM; /* Sound the alarm. */ END;

CALL MSPUT(1, /* Add ADS data to map on page*/ D WRITE, /* with write operation, */ INITSEL_ASLENGTH, /* specifying ADS length */ INITSEL); /* and data area. */

CALL ASREAD(ATTYPE, /* Send mapped page to */ ATVAL, /* terminal and wait for */ COUNT); /* end-user input. */

CALL MSGET(1,0, /* Get response into ADS. */ INITSEL_ASLENGTH, INITSEL);

SELECT (ATTYPE); /* Analyze interrupt type - */ E WHEN (0) DO; /* ENTER key, so inspect */ F IF OPTION_CURSOR(1) = '1' /* the cursor adjuncts */ G THEN CALL CPROC; /* to see which field */ ELSE IF OPTION_CURSOR(2) = '1' /* (if any) the cursor */ THEN CALL DPROC; /* was in. */ ELSE IF OPTION_CURSOR(3) = '1' THEN CALL PPROC; ELSE IF OPTION_CURSOR(4) = '1' THEN PROCESS = '0'B; ELSE INVALID = '1'B; /* Not in a valid field. */ END; /* End cursor inspection.*/

WHEN (1) /* PF key interrupt, so */ H SELECT (ATVAL); /* analyze the value */ I WHEN (10) CALL CPROC; /* returned in ATVAL. */ WHEN (11) CALL DPROC; WHEN (12) CALL PPROC; WHEN (3) PROCESS = '0'B; OTHERWISE INVALID = '1'B; /* Invalid PF key chosen.*/ END; /* End PF key inspection.*/

WHEN (2) DO; /* Light pen, so analyze */ I IF OPTION_SEL(1) = '1' /* the selector adjuncts */ J THEN CALL CPROC; /* to see which field */ ELSE IF OPTION_SEL(2) = '1' /* was selected. */ THEN CALL DPROC; ELSE IF OPTION_SEL(3) = '1' THEN CALL PPROC; ELSE PROCESS = '0'B; END; /* End l-pen inspection. */

OTHERWISE INVALID = '1'B; /* Invalid interrupt. */ K END; /* End select group. */

END; /* End DO WHILE loop. */

CALL FSTERM; /* Terminate GDDM. */

%INCLUDE ADMUPINA; /* GDDM entry declarations */ %INCLUDE ADMUPINF; %INCLUDE ADMUPINM;

END MAPEX08;


Figure 91. Listing of MAPEX08 source code



   PICTURE 54          

Figure 92. Field definitions of map used by MAPEX08


Go to the previous page Go to the next page



Copyright IBM Corporation 1990, 2012