GML Look-Up Manager (LUM) : Responding To Events

The GML LUM must be called when list edit or list button events occur (GOSUB LUM_LOOK_UP). In addition, when other events occur, the LUM must be called to determine when to hide a look-up control (GOSUB LUM_EVENT) that is visible (GML_LUM_FLAG%<>0 ), but focus has been moved elsewhere. Line 3650 as follows is an example that contains the necessary code to provide access to the subroutines that provide access to the GML LUM to administer the events. This line of code should must be inserted in the application immediately following the line of code that transfers program control to the routine that manages the grid events (see line 3640).

The actual location of the following code, and names of sub routines are application specific. The following is intended to illustrate the items necessary to manage the events.

3640 IF EVENT.CODE$="N" THEN IF NOTICE.OBJTYPE%=107 THEN GOSUB GML_M; CONTINUE   
3650 IF EVENT.CODE$="N" AND NOTICE.OBJTYPE%>18 AND NOTICE.OBJTYPE%<21
       THEN GOSUB LUM_LOOK_UP
            ELSE IF EVENT.CODE$<>"m" AND GML.LUM_FLAG% THEN GOSUB LUM_EVENT

LUM_LOOK_UP Subroutine

In the LUM_LOOK_UP subroutine, the event ID is placed in GML_LUM.EVENT_ID% and the event context is placed in GML_LUM.EVENT_CONTEXT% variables. The Look-Up Manager is then called by executing the call to the GML to find the index of the look-up control identified by the event ID and context.

7620 LUM_LOOK_UP:
7630 REM +----------------------+
7640 REM ! FIND LOOK-UP INDEX !
7650 REM +----------------------+
7660 GML_LUM.EVENT_ID%=EVENT.ID%
7670 GML_LUM.EVENT_CONTEXT%=EVENT.CONTEXT%
7680 CALL "GML::LUM_FIND"

If after execution of the call to the GML, variable GML_LUM.LU_SET% contains a 0 (the control is not a look-up type control), the subroutine ends by branching to the RETURN in line 8010

7690 IF GML_LUM.LU_SET%=0 THEN GOTO 8010

In the next portion of the subroutine, template variable NOTICE.CODE% is used with the SWITCH verb to determine how to manage the event (see VPRO/5 documentation relating to List Button and List Edit Notify Events for more information)

When an event is generated by a list opened (CASE 1) no action is necessary, and the subroutine ends.

7700 SWITCH NOTICE.CODE%
7710 REM +---------------+
7720 REM ! LIST OPENED !
7730 REM +---------------+
7740 CASE 1
7750 BREAK

When an item is selected, the value of the GML_LUM.LU_SET% variable is placed into the GML.SET% variable. GML is called to prepare the GML_TPL$ template, and then GML LUM is called to get the text from the look-up control that generated the event. GML LUM places the text into the GML_TPL$ template GML_TPL.COL$[n] variable. The [n] is the sum of values in variables GML_LUM.COL%[GML_LUM.LU_SET%] and GML_LUM.LOC%[GML_LUM.LU_SET%]. The event row number is placed in the GML_TPL.ROW_N% variable. The POPULATE procedure is then executed to update the text in the main grid cell.

7760 REM +-----------------+
7770 REM ! ITEM SELECTED !
7780 REM +-----------------+
7790 CASE 2
7800 GML.SET%=GML_LUM.LU_SET%
7810 CALL "GML::TPL_PREP"
7820 CALL "GML::LUM_GET_TEXT"
7830 CALL "GML::POPULATE"
7840 BREAK

When an event is generated by a list closed (CASE 3) or a cancellation of the selection process (CASE 4), GML LUM is called to hide the control.

7850 REM +---------------+
7860 REM ! LIST CLOSED !
7870 REM +---------------+
7880 CASE 3
7890 REM +-------------------------------+
7900 REM ! SELECTION PROCESS CANCELLED !
7910 REM +-------------------------------+
7920 CASE 4
7930 CALL "GML::LUM_HIDE"
7940 BREAK

When an event is generated by a selection change (CASE 5), no action is necessary, and the subroutine ends.

7950 REM +---------------------+
7960 REM ! SELECTION CHANGED !
7970 REM +---------------------+
7980 CASE 5
7990 BREAK
8000 SWEND
8010 RETURN

Listing of the LUM_LOOK_UP Subroutine:

7620 LUM_LOOK_UP:
7630 REM +----------------------+
7640 REM ! FIND LOOK-UP INDEX !
7650 REM +----------------------+
7660 GML_LUM.EVENT_ID%=EVENT.ID%
7670 GML_LUM.EVENT_CONTEXT%=EVENT.CONTEXT%
7680 CALL "GML::LUM_FIND"
7690 IF GML_LUM.LU_SET%=0 THEN GOTO 8010
7700 SWITCH NOTICE.CODE%
7710 REM +---------------+
7720 REM ! LIST OPENED !
7730 REM +---------------+
7740 CASE 1
7750 BREAK
7760 REM +-----------------+
7770 REM ! ITEM SELECTED !
7780 REM +-----------------+
7790 CASE 2
7800 GML.SET%=GML_LUM.LU_SET%
7810 CALL "GML::TPL_PREP"
7820 CALL "GML::LUM_GET_TEXT"
7830 CALL "GML::POPULATE"
7840 BREAK
7850 REM +---------------+
7860 REM ! LIST CLOSED !
7870 REM +---------------+
7880 CASE 3
7890 REM +-------------------------------+
7900 REM ! SELECTION PROCESS CANCELLED !
7910 REM +-------------------------------+
7920 CASE 4
7930 CALL "GML::LUM_HIDE"
7940 BREAK
7950 REM +---------------------+
7960 REM ! SELECTION CHANGED !
7970 REM +---------------------+
7980 CASE 5
7990 BREAK
8000 SWEND
8010 RETURN

LUM_EVENT Subroutine

3650 IF EVENT.CODE$="N" AND NOTICE.OBJTYPE%>18 AND NOTICE.OBJTYPE%<21
       THEN GOSUB LUM_LOOK_UP
            ELSE IF EVENT.CODE$<>"m" AND GML.LUM_FLAG% THEN GOSUB LUM_EVENT

Program control is transferred to the LUM_EVENT subroutine when the value of variable GML.LUM_FLAG% is not equal to 0, and an event other than a list control or mouse event has occurred. In the LUM_EVENT subroutine, the event ID is placed in GML_LUM.EVENT_ID% and the event context is placed in GML_LUM.EVENT_CONTEXT% variable. The Look-Up Manager is then called by executing a call to the GML to determine if the look-up control has lost focus, and hide the control as required.

7420 LUM_EVENT:
7430 GML_LUM.EVENT_ID%=EVENT.ID%
7440 GML_LUM.EVENT_CONTEXT%=EVENT.CONTEXT%
7450 CALL "GML::LUM_EVENT"
7460 RETURN