Progress
Language Tutorial
for Character


Accessing Widget Attributes and Methods

Usually, the default attribute values assigned implicitly by Progress statements provide the appearance and functionality you want in your widgets. However, Progress also supports a syntax that lets you access attribute information directly. This syntax is shown below.

SYNTAX
ASSIGN widget-name:attribute-name 

To display an attribute’s value, all you have to do is reference it in a DISPLAY statement, as shown below:

DISPLAY widget-name:attribute-name WITH Frame1. 

You can also assign widget attribute values to variables, as long as the variable is of the same data type, using the following syntax.

SYNTAX
ASSIGN var-name = widget-name:attribute-name 

To set an attribute, you assign the new value to the attribute, but you must also specify the frame in which the widget resides. You use the IN FRAME phrase to identify the containing frame. Here is the syntax.

SYNTAX
ASSIGN widget-name:attribute-name IN FRAME frame-name = value 

Follow these steps for a demonstration of widget attributes:

  1. Open lt-03-10.p.
  2. Choose Compile Run. You see a fill-in field with the label “Is Rectangle Visible?” and the value no.
  3. Choose the Show Rectangle button. A rectangle becomes visible and the value of the fill-in field becomes yes, as shown below:
  4. Choose Exit to end the procedure.
  5. Press SPACEBAR to return to the Procedure Editor.

This is the code that created the display:

lt-03-10.p
    /**********  DEFINE FIELD-LEVEL WIDGETS  **********/
    DEFINE RECTANGLE Rect1 SIZE-CHARS 10 BY 4 EDGE-CHARS 1.
    DEFINE VARIABLE Field1 AS LOGICAL LABEL "Is Rectangle Visible?".
    DEFINE BUTTON btn-Rect LABEL "Show Rectangle".
    DEFINE BUTTON btn-Exit LABEL "Exit".

    /**********  DEFINE FRAMES  **********/
    DEFINE FRAME Frame1
        SKIP(1) Rect1 SKIP(1) Field1 SKIP(1) btn-Rect SKIP(2) btn-Exit
            WITH SIDE-LABELS NO-BOX CENTERED THREE-D.

    /**********  DEFINE TRIGGERS  **********/
    ON CHOOSE OF btn-Rect
    DO:
/*3*/   ASSIGN Rect1:VISIBLE = YES
/*4*/           Field1 = Rect1:VISIBLE.
/*5*/   DISPLAY Field1 WITH FRAME Frame1.
        DISABLE btn-Rect WITH FRAME Frame1.
    END. /* ON CHOOSE OF btn-Rect */

    /**********  MAIN LOGIC  **********/
/*1*/  ASSIGN Rect1:VISIBLE = NO
/*2*/      Field1 = Rect1:VISIBLE.
      DISPLAY Field1 WITH FRAME Frame1. 
      ENABLE Field1 btn-Rect btn-Exit WITH FRAME Frame1.
      WAIT-FOR CHOOSE OF btn-Exit. 

These notes help explain the code:

  1. When you first create a widget, the VISIBLE attribute is set to YES by default. However, a field-level widget is not visible until its frame is visible. Therefore, when a frame becomes visible, all the widgets in it are visible by default. In this statement, you set the VISIBLE attribute to NO. When the frame displays, you won’t see the rectangle.
  2. You assign the value of the rectangle’s VISIBLE attribute to Field1.
  3. When the user chooses the button, the trigger changes the value of the VISIBLE attribute to YES, making the widget visible, since its frame is currently visible.
  4. You assign the new value of the VISIBLE attribute to Field1.
  5. The DISPLAY statement outputs the new value of Field1 to the screen.

This example also illustrates an important rule about accessing attributes for field-level widgets: You cannot access a widget’s attributes until that widget is referenced in a frame.

Methods

A method is a specialized function that modifies how a widget works. For example, the READ-FILE method allows you to read an operating system file into an editor widget. Methods are relatives of attributes and you access them in the same way you access attributes.

To use a method, follow these basic steps:

  1. Reference the widget using the standard attribute syntax.
  2. Supply any input parameters required by the method.
  3. Assign the result of the method call to a variable of the same data type.

Here’s an example:

ASSIGN variable-name = widget-name:method-name(parameter-name). 

The later chapters of the tutorial discuss some of the most useful methods.


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