Progress
Language Tutorial
for Character


Enabling and Disabling Widgets

As you’ve seen in previous examples, you use the ENABLE and DISABLE statements to turn widgets on and off. Typically, when you present an interface, you enable all the widgets in that interface. At other times, some widgets don’t have to be enabled unless special conditions are met.

Follow these steps for a demonstration of how you can enable and disable widgets during run time:

  1. Open lt-03-08.p.
  2. Choose Compile Run. The interface shown below appears. Note that buttons #1 and Exit are enabled, and #2 is disabled:
  3. Choose the first button. The second button becomes enabled and the first becomes disabled.
  4. Choose the second button. The first button becomes enabled again and the second button becomes disabled. You can repeat this process as many times as you like.
  5. Choose Exit to end the procedure.
  6. Press SPACEBAR to return to the Procedure Editor.

Here is the code that created the display:

lt-03-08.p
    /**********  DEFINE FIELD-LEVEL WIDGETS  **********/
    DEFINE BUTTON btn-One LABEL "#1".
    DEFINE BUTTON btn-Two LABEL "#2".
    DEFINE BUTTON btn-Exit LABEL "Exit".

    /**********  DEFINE FRAMES  **********/
    DEFINE FRAME Frame1
      SKIP(2) btn-One btn-Two btn-Exit
        WITH NO-BOX CENTERED THREE-D.

    /**********  DEFINE TRIGGERS  **********/
    ON CHOOSE OF btn-One
    DO:
/*1*/  ENABLE btn-Two WITH FRAME Frame1.
       DISABLE btn-One WITH FRAME Frame1.
    END. /* ON CHOOSE OF btn-One */
    ON CHOOSE OF btn-Two
    DO:
/*2*/  ENABLE btn-One WITH FRAME Frame1.
       DISABLE btn-Two WITH FRAME Frame1.
    END. /* ON CHOOSE OF btn-Two */

    /**********  MAIN LOGIC  **********/
    ENABLE btn-One btn-Exit WITH FRAME Frame1.
    WAIT-FOR CHOOSE OF btn-Exit. 

The effect of the ENABLE and DISABLE statements at points 1 and 2 is that only one of the buttons can be active at a time. By selectively enabling and disabling parts of the interface, you help the user focus on the parts of the interface that are important at a given moment.

This is a partial syntax for the ENABLE statement.

SYNTAX
ENABLE { ALL | SKIP [ (n) ] | widget-list } 
  { [ frame-phrase ] } 

This is a partial syntax for the DISABLE statement.

SYNTAX
DISABLE { ALL | widget-list } { [ frame-phrase ] } 

The following table describes the important elements of the ENABLE and DISABLE statements:

Element
Description
ALL
Applies the statement to every widget in the specified frame.
frame-phrase 
Specifies the frame where the targeted widgets exist. Even when Progress does not require it, it is good programming practice to specify the frame.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095