Using Multiple Panels

RM/Panels is designed to support windowed applications, where panels can be displayed (or “pop-up”) at different locations on the screen. While simple to produce, this type of application requires a few special considerations. The following describes the three steps to writing pop-up applications.

  1. Detect a request for a pop-up panel. The first step in coding a windowed application is detecting the conditions that indicate the need to display the pop-up panel. This can be any condition, but is commonly a special keystroke, push button, or menu command. The detection is usually a test inside an event loop based on the EXECUTE EVENT standard runtime function. This is illustrated by the following code fragment:

    DEMONSTRATE-FUNCTION. 
       PERFORM RMP--EE-PANEL5.
       IF F3-KEY AND (RMP--LAST-FIELD = "CUST-SHIP-CODE") 
          PERFORM SHIP-CODE-DETAILS

    When the F3 key is pressed during the entry of the CUST-SHIP-CODE field, the SHIP-CODE-DETAILS procedure, which controls the pop-up panel, is performed.

  2. Display, use, and remove the pop-up panel. A pop-up panel is used like any other panel, but with one important difference. The “Make panel a window” parameter must be selected, or at runtime execution, RMP--WINDOW should be set to TRUE before the panel is displayed. Failure to do one of these will prevent the panel from being removed from the display properly.

    The following code fragment shows how the pop-up panel is displayed, used, and removed:

    SHIP-CODE-DETAILS.
        PERFORM RMP--DP-PANEL6.
        SET RMP--FIRST-FIELD TO TRUE. 
        PERFORM RMP--EE-PANEL6
           WITH TEST AFTER UNTIL ESCAPE-KEY. 
        PERFORM RMP--RP-PANEL6.

    Since this panel was created with the windowing option selected, the code is no different from the usage of a normal panel. The panel is displayed, an event loop is used for user input, and then the panel is removed, restoring the screen contents.

  3. Resume execution of the original event loop. The event loop is based on the ability of the EXECUTE EVENT standard runtime function to perform an input event and set up the next input event. Because the previous step includes an event loop that actually executes inside the original event loop, the internal variables determining which field/control should be entered next are set for the pop-up panel. One of these must be reset so that the keyboard focus moves to a field/control on the main panel. There are three ways to do this:
    1. Set RMP--REPEAT-EVENT to TRUE.

      This returns keyboard focus to the last field/control that had it on the panel.

    2. Set RMP--FIRST-FIELD to TRUE.

      This sets keyboard focus to the first enabled field/control on the panel.

    3. Move the name of a field to RMP--NEXT-FIELD.

      This specifically moves keyboard focus to that field/control.

    Also, care must also be taken not to allow the terminating condition from the inner loop to terminate the original loop. The following program prevents this problem by moving zero to RMP--EXCEPTION-NUMBER, so that the Escape key condition is false upon resuming the original loop. The following code follows the sample shown in the first step.

       SET RMP--REPEAT-EVENT TO TRUE 
       MOVE 0 TO RMP--EXCEPTION-NUMBER.