Progress
Language Tutorial
for Character


Manipulating Widget Attributes

Widgets have many attributes that you can access and change even when the widget is visible on screen. By changing attributes, you can change the appearance or function of the widget. For example, you might want to:

Follow these steps for a demonstration of attributes in expressions:

  1. Open lt-05-02.p and run it. The interface is shown below:
  2. Experiment by choosing from the Up, Down, Left, Right button group. The Reset button moves. You can move the button around within the frame, but can’t move the button beyond the borders of the frame. The ROW and COL attributes, which the buttons manipulate, position a widget within a frame.
  3. Choose the Reset button to move it back to its starting location.
  4. Choose Exit, then press SPACEBAR to return to the Procedure Editor.

Here is the code that created the display:

lt-05-02.p
      /**********  DEFINE WIDGETS  **********/
      DEFINE BUTTON btn-Up    LABEL " Up ".
      DEFINE BUTTON btn-Down  LABEL "Down".
      DEFINE BUTTON btn-Right LABEL "Right".
      DEFINE BUTTON btn-Left  LABEL "Left".
      DEFINE BUTTON btn-Reset LABEL "Reset".
      DEFINE BUTTON btn-Exit  LABEL "Exit". 
      /**********  DEFINE FRAMES  **********/
      DEFINE FRAME Frame1
        btn-Reset AT ROW  8 COLUMN 1
        btn-Up    AT ROW 10 COLUMN 8
        btn-Down  AT ROW 12 COLUMN 8
        btn-Left  AT ROW 11 COLUMN 1
        btn-Right AT ROW 11 COLUMN 15
        btn-Exit  AT ROW 13 COLUMN 1
            WITH SIZE-CHARS 40 BY 14 CENTERED THREE-D. 
      /**********  DEFINE TRIGGERS  **********/    
/*1*/  ON CHOOSE OF btn-Reset IN FRAME Frame1 DO:
      ASSIGN btn-Reset:ROW = 8
               btn-Reset:COL = 1.           
       END.
/*2*/  ON CHOOSE OF btn-Up DO:
        IF btn-Reset:ROW <> 1 THEN
          ASSIGN btn-Reset:ROW = btn-Reset:ROW - 1.     
       END.
/*3*/  ON CHOOSE OF btn-Down DO:
        IF btn-Reset:ROW <> 8 THEN
          ASSIGN btn-Reset:ROW = btn-Reset:ROW + 1. 
       END.
/*4*/  ON CHOOSE OF btn-Right DO:
        IF btn-Reset:COL <> 30 THEN
          ASSIGN btn-Reset:COL = btn-Reset:COL + 1.
       END.
/*5*/  ON CHOOSE OF btn-Left DO:
        IF btn-Reset:COL <> 1 THEN
          ASSIGN btn-Reset:COL = btn-Reset:COL - 1.
       END.
      /**********  MAIN LOGIC  **********/
      ENABLE ALL WITH FRAME Frame1.
      WAIT-FOR CHOOSE OF btn-Exit.    

The following notes help explain the code:

  1. Choosing the Reset button moves the widget back to its starting location. The trigger assigns the constant values that correspond to the original coordinates to the ROW and COL attributes.
  2. This trigger moves the Reset button up one row by decrementing ROW.
  3. This trigger moves the Reset button down one row by incrementing ROW.
  4. This trigger moves the Reset button right one column by incrementing COL.
  5. This trigger moves the Reset button left one column by decrementing COL.
  6. Practice Problems

    If you feel like you need some practice writing expressions, complete the exercises below. The filename listed next to each problem contains a sample solution. You can load the file into the Procedure Editor.

    Problem 5-1 lt-05-s1.p

    Using a FOR EACH block, increase all customer credit limits by 10%. Display the customer name, old credit limit, and new credit limit.

    Problem 5-2 lt-05-s2.p

    Display all customer names and balances where the balance is $5000 or more.

    Problem 5-3 lt-05-s3.p

    Display all orders that were placed between 1/14/93 and today.

    Problem 5-4 lt-05-s4.p

    Display all orders that have not been shipped within five days of the promised date.

    Problem 5-5 lt-05-s5.p

    Based on today’s date, display the number of the month, weekday, and year.

    Problem 5-6 lt-05-s6.p

    Define an array of dates called Holidays. Initialize the array with the dates you get off from work. Label each element with the holiday name. Display the result.


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