Event Procedures, Embedded Procedures, and Code Insertion Points

The procedures and code insertion points listed on the Event tab of the Screen Designer Property window vary according to the type of control selected. Display-only controls, such as bars, frames, and entry fields, for example, do not have any procedures or code insertion points associated with them. In general, the more complex the control (and therefore the more ways a user can respond to a control), the more event and exception procedures can be associated with a control.

If you select a screen, for example, and expand the list in the Event tab of the Property window, you see the following procedures and insertion points:

The code insertion points are unique to AcuBench screens. These procedures (Before Create, After Create, Before Initdata, After Initdata, Before Routine, and After Routine) can be defined and inserted around generated code paragraphs. Before Create code that you define, for example, is performed just before the AcuBench-generated DISPLAY code for the screen. You might insert a paragraph here to load the data you want to see when the screen is displayed. After Initdata code is performed just after the AcuBench-generated Initdata code used to define the data structure for complex screen controls, like combo boxes, grids, and tree view controls. You might insert a paragraph here to manually load data into any of these controls.

Event, exception, and embedded procedures, on the other hand, can be assigned to ACUCOBOL-GT screens and controls regardless of whether or not you are working in AcuBench. These procedures follow the structure and rules discussed in Events Reference and Data Division.

One special AcuBench embedded procedure type is the Link-To paragraph. A Link-To paragraph is a way to assign a specific exception value to certain screen elements. When a user clicks a screen element that has a Link-To value assigned, the specified exception is sent to the program, which then performs the procedure associated with that exception.

Both Link-To and Cmd-Clicked procedures are invoked when the user clicks a screen element. In the former case, a manually-assigned exception value is generated, updating the Key-Status data structure and invoking a procedure associated with the specified value.

        WHEN Key-Status = 211
           PERFORM Client-Scr-Pets-Pb-Link

When a Cmd-Clicked exception procedure has been assigned to a screen element and a user clicks the control, an Event-Occurred message (exception value 96) is sent to the program, which then determines which control generated the exception, which event actually occurred, and whether or not a procedure exists to respond to that event.