The event loop method enables sophisticated screen handling with tremendous flexibility and greatly reduced coding.
There are three components in an event loop:
- Loop control. This specifies the condition or conditions that terminates the loop.
- Execution of an event. One event occurs on each repetition of the loop, until the loop control conditions are met.
- Event testing. One or more checks by the application program to evaluate events. Rather than dictating each event, the application
program responds to the current event.
Example of an RM/Panels Event Loop
PERFORM UNTIL F3-KEY-PRESSED (Loop Control)
PERFORM RMP--EE-PANELNAME (Execution)
EVALUATE RMP--LAST-FIELD
WHEN "CUSTOMER-NUMBER" (Event Test)
PERFORM VALIDATE-CUSTOMER-NUMBER
WHEN "CUSTOMER-STATE" (Event Test)
PERFORM VALIDATE-CUSTOMER-STATE
END-EVALUATE
END-PERFORM.
The event is input to a field/control on the screen, which is performed by the procedure
RMP--EE-PANELNAME. This procedure executes the RM/Panels EXECUTE EVENT standard run-time function. The EXECUTE EVENT standard run-time function
accomplishes the following:
- Checks the parameters passed to it to see what event to perform
- Performs the event (field/control input)
- Sets parameters to indicate what event was executed and what event should be executed next
- Returns control to the application program
Each time the EXECUTE EVENT standard run-time function is performed, only one event is executed, thus the application program
can always intercept control after any event. It then has the ability to perform special processing or force a particular
event to occur.
There are many advantages to using the event loop method:
- Writing tedious screen handling code is eliminated.
- Adding special field/control level logic is made easier.
- Field/control level logic is insulated from changes in field/control entry order and position.
- Size of screen handling code is dependent upon the amount of special processing to be done, rather than the number of fields/controls
on the screen.
- Adding new fields/controls does not affect the event loop unless the fields/controls require special processing.
- Event loops can be nested, which allows multiple panels to be used on the screen. The following section describes the use
of multiple panels and special considerations in nesting event loops.