Progress
Language Tutorial
for Windows
Referencing Widgets
A field or variable name is both a valid reference to the value associated with the field or variable and to the widget associated with the field or variable. For example, in the first statement below, referencing Field1 and Variable1 in an expression manipulates their values. In the second and third statements, referencing the names in a screen I/O statement manipulates the widgets associated with them. Review these statements in the following code:
This example also demonstrates the difference between using the frame phrase or IN FRAME to make an unambiguous reference to a widget. A single screen I/O statement can only work with the widgets in one frame. Thus the reference to the frame in the frame phrase creates an unambiguous reference to all widgets in the frame. On the other hand, you can append the
IN FRAME syntax to any widget reference in any other statement to make a single widget reference unambiguous.Referencing Widget Attributes
You also use the IN FRAME syntax to make unambiguous widget attribute references. Recall that the basic syntax for accessing a widget attribute is as follows.
You append the IN FRAME syntax to the widget attribute reference to make the reference unambiguous, as follows:
For example, the assignment statement below assigns an attribute value to a variable:
Referencing Widget Methods
A method is a function associated with a particular type of widget that you access to manipulate an individual widget. You access methods in the same way that you access attributes.
Like a function, a method always returns a value. For methods, that value is usually LOGICAL and indicates whether or not Progress successfully applied the method to the widget. Methods also may use input and output parameters like a function.
Later in the chapter you’ll see programming examples that use methods.
Using Widget Handles
Using the field or variable name as a reference to both value and widget is convenient and makes readable code. At times, you may need to specifically reference the widget and not its associated field or variable. In these cases, you need to provide the widget handle. A widget handle is a unique internal identifier for a widget. Every widget has an attribute named HANDLE that contains the widget handle for that widget.
To access the handle, use the syntax presented in this example:
You may also want to save the handle of a widget in a variable. Since Progress supports widget handles as a separate data type, you need to specify the WIDGET-HANDLE data type in your DEFINE VARIABLE statements as this shows:
Progress maintains several global variables that contain widget handles. These variables are part of a group of language elements known as system handles. System handles allow you to access information about the system. Table 7–4 describes the system handles that you can use to access information about widgets.
Widget Referencing Programming Example
The following exercise demonstrates widget referencing and system handles:
Here is the code for this procedure:
The following notes describe the code highlights:
- The first frame contains the text widgets that track the user’s actions.
- The second frame contains the buttons.
- This trigger executes when any of the four buttons receive the ENTRY event. Notice the IN FRAME syntax for specifying the location of the widgets.
- The ENTRY event occurs before Progress actually moves input focus. This APPLY statement forces Progress to fully move focus to the new widget. Notice the SELF system handle. No matter which button executes the trigger, Progress evaluates this statement using the correct button.
- You can access an attribute of FOCUS or SELF exactly as you would with an explicit widget reference.
- On this screen I/O statement, the frame phrase option specifies the correct frame.
- Choosing any button except Exit executes this trigger.
- Again, you access the system handle attribute exactly as you would a named widget.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |