Progress
Language Tutorial
for Windows


Toggle Box Programming Example

Follow these steps to see how to use VALUE-CHANGED:

  1. Open lt-07-05.p and run it. The following display appears:
  2. Only the toggle box and Exit button are sensitive. Activate the toggle box. A VALUE-CHANGED trigger calculates the tax and new total.
  3. Note that if you pause your mouse pointer over the toggle box a ToolTip is displayed.

  4. Deactivate the toggle box. The VALUE-CHANGED trigger executes again and calculates the total without the tax.
  5. Choose Exit, then press SPACEBAR to return to the Procedure Editor.

Here is the code that created the display:

lt-07-05.p
      /**********  DEFINE WIDGETS  **********/
      DEFINE VARIABLE Item AS CHARACTER INITIAL "Backpack".
      DEFINE VARIABLE Price AS DECIMAL INITIAL 29.95.
      DEFINE VARIABLE Tax AS DECIMAL INITIAL 0.00.
      DEFINE VARIABLE TOTAL AS DECIMAL.
/*1*/  DEFINE VARIABLE Taxable AS LOGICAL LABEL "Taxable Sale?" 
          VIEW-AS TOGGLE-BOX TOOLTIP "Checkmark indicates tax is 
           included".
      DEFINE BUTTON btn-Exit Label "Exit".

      /**********  DEFINE FRAMES  **********/    DEFINE FRAME Frame1
          SKIP(1) Item COLON 7 SKIP
          Price COLON 7 SKIP
          Tax COLON 7 SKIP
          TOTAL COLON 7 SKIP(2)
          Taxable SKIP(2)
          btn-Exit
/*2*/          WITH NO-BOX CENTERED SIDE-LABELS USE-TEXT THREE-D. 
      /**********  DEFINE TRIGGERS  **********/
/*3*/  ON VALUE-CHANGED OF Taxable
       DO:
          ASSIGN Taxable.
          IF Taxable = YES THEN
              ASSIGN Tax = Price * 0.05
                   TOTAL = Price + Tax.
          ELSE
              ASSIGN Tax = 0.00
                    TOTAL = Price + Tax.
          DISPLAY Tax Total WITH FRAME Frame1.
       END. 
      /**********  MAIN LOGIC  **********/
      DISPLAY Item Price Tax TOTAL Taxable WITH FRAME Frame1.
      ENABLE ALL WITH FRAME Frame1.     
      WAIT-FOR CHOOSE OF btn-Exit. 

These notes explain the code highlights:

  1. This statement creates the toggle box.
  2. USE-TEXT converts the fill-in fields to text widgets without affecting other widgets.
  3. Whenever you change the screen value of the widget, VALUE-CHANGED executes, forcing the appropriate calculation and update.
NOTE: The TOOLTIP attribute noted in the code example is ignored when this code is run on a character client.


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