Built-ins in Forms control various user actions at runtime. These actions are nothing but the logical Forms functions that happen at runtime. User navigation or invoking list values for a data- bearing item are examples of such actions. Corresponding to each of these actions or logical functions are physical function keys that can initiate these actions, in addition to the programmatic control through built-ins. Also, for each of these physical function keys, there is a KEY- trigger to customize physical its default action. For example, writing a KEY-LISTVAL trigger can replace the default function of LIST_VALUES with more advanced code.
Forms has provided a common built-in named DO_KEY to customize these actions, irrespective of whether these actions were initiated by a built-in or a physical function key. This section attempts to highlight the subtle differences of using a KEY- trigger, a corresponding built-in, and the DO_KEY built-in with examples. Also, it goes a little beyond this to pinpoint the use of EXECUTE_TRIGGER in reference to the earlier ones.
Table 2.1 gives a clear picture of the differences among the following:
Table 2.1. Correspondence between Logical Function Key, Physical Function Key, KEY- trigger, built-in and DO_KEY.
Item | Item Value | Item Description |
---|---|---|
Logical Function key | List of Values | The logical key to pop up an LOV for an item. |
Physical key | F9 | The physical hot key for invoking an LOV when the cursor is inside an item. |
KEY- trigger | KEY-LISTVAL | The KEY trigger to add logic to the default process of popping up an LOV (for example, to check runtime conditions). Fires only when the user presses the hot key. |
Built-in | LIST_VALUES | The Forms built-in to invoke an LOV. Can be called from any trigger that allows it. |
DO_KEY | DO_KEY('LIST_VALUES') | Checks whether a KEY-LISTVAL trigger is defined. If Yes, executes this KEY trigger; if No, executes just the built-in. Can be called from any trigger including KEY-LISTVAL ; when called from KEY-LISTVAL, has the same effect as LIST_VALUES. Takes a valid KEY- trigger “ related built in as an argument. |
EXECUTE_TRIGGER | EXECUTE_TRIGGER ('KEY-LISTVAL') | Takes any trigger name as an argument, provided that the scope of the trigger supplied as theparameter makes sense. For example, EXECUTE_TRIGGER('MY_TRIGGER'), where MY_TRIGGER is a user-defined trigger. If, instead of a user-defined trigger, a Forms predefined trigger is being called using EXECUTE_TRIGGER, the scope of the trigger calling the EXECUTE_TRIGGER and the scope of the parameter trigger should match. |
As an example of EXECUTE_TRIGGER (the last item in the above table), the following code, although commonly written in the KEY- NEXT -ITEM trigger,
EXECUTE_TRIGGER('WHEN-VALIDATE-ITEM'); IF FORM_SUCCESS THEN
can be called from any trigger, such as WHEN-BUTTON-PRESSED, keeping in mind the restriction just mentioned.
Tip
Use DO_KEY by default whenever there is a need to execute a function corresponding to a KEY- trigger.
The DO_KEY built-in executes the function key trigger associated with the built-in specified as its argument, irrespective of the trigger in which it is specified.
For example, the code
DO_KEY('NEXT_RECORD');
behaves in the following way. If a separate KEY-NXTREC trigger is written, the built-in executes this trigger; otherwise , it executes the function NEXT_RECORD (that is, it just navigates to the next record). It doesn't matter whether the user presses the function key. In fact, pressing the function key is not mandatory. On the other hand, for KEY-NXTREC to execute without the DO_KEY, the user must explicitly press . Otherwise, KEY-NXTREC is called as an argument to EXECUTE_TRIGGER, in which case it fires even without the user pressing .
Tip
There is a significant difference between DO_KEY and EXECUTE TRIGGER. The former fires even when is pressed and the latter doesn't, which defeats the purpose of writing a KEY-NXTREC trigger when an action is required on user navigation.
In addition, the EXECUTE_TRIGGER takes any name, not only predefined trigger names .
GUI Development
Advanced GUI Development: Developing Beyond GUI
Multi-form Applications
Advanced Forms Programming
Error-Message Handling
Object-oriented Methods in Forms
Intelligence in Forms
Additional Interesting Techniques
Working with Trees
Oracle 8 and 8i Features in Forms Developer