Progress
Language Tutorial
for Windows


Selection-list Programming Example

Although the selection list is valuable for presenting a list of known choices to a user, it becomes essential as a way to display acceptable choices that aren’t known until run time. The process of filling the list of choices at run time is known as populating. Populating involves two major steps:

  1. Use the VIEW-AS phrase without the LIST-ITEMS option. This allows the Progress compiler to define the widget for use at runtime.
  2. Define the list items of the widget before you display it.

All Around Sports is a growing business, and the responsibilities of its sales people are changing to meet the new challenges. The sales director asks you to design a simple interface so that she can quickly view and change sales representative assignments.

Follow these steps to view a sales representative selection list:

  1. Open lt-07-08.p and run it. The following display appears:
  2. Click an item to choose it. The form does not update. If the trigger in the procedure used VALUE-CHANGED, it would have.
  3. Double-click a sales representative name, Progress accesses the appropriate record from the sports database and displays some of the fields. The double-click event executes the DEFAULT-ACTION trigger for the selection list.
  4. Choose Exit, then press SPACEBAR to return to the Procedure Editor.

This is the code that created the interface:

lt-07-08.p
      /**********  DEFINE WIDGETS  **********/
/*1*/  DEFINE VARIABLE Reps AS CHARACTER VIEW-AS SELECTION-LIST 
          INNER-CHARS 25 INNER-LINES 9 SORT.
      DEFINE VARIABLE Stat AS LOGICAL.
      DEFINE BUTTON btn-Exit LABEL "Exit".
      /**********  DEFINE FRAMES  **********/
      DEFINE FRAME Frame1
          Reps NO-LABEL      AT ROW 2 COLUMN 3
         Salesrep.Sales-Rep AT ROW 2 COLUMN 35
         Salesrep.Rep-Name  FORMAT "x(20)" AT ROW 3 COLUMN 36
          Salesrep.Region    AT ROW 4 COLUMN 38
          btn-Exit           AT ROW 9 COLUMN 3 SKIP(1)
             WITH SIDE-LABELS CENTERED ROW 2 TITLE "Update Sales Rep Info"
                 THREE-D.
      /**********  DEFINE TRIGGERS  **********/
/*2*/  ON DEFAULT-ACTION OF Reps
       DO:
           ASSIGN Reps.
          FIND FIRST Salesrep WHERE Salesrep.Rep-Name = Reps.
         DISPLAY Salesrep.Sales-Rep Salesrep.Rep-Name Salesrep.Region 
            WITH FRAME Frame1.
       END.
      /**********  MAIN LOGIC  **********/
/*3*/  Reps:DELIMITER = "*".
/*4*/  FOR EACH Salesrep BY Salesrep.Rep-Name:
/*5*/      Stat = Reps:ADD-LAST(Salesrep.Rep-Name).
       END.
/*6*/  FIND FIRST Salesrep.
     DISPLAY Reps Salesrep.Sales-Rep Salesrep.Rep-Name Salesrep.Region
          WITH FRAME Frame1.
      ENABLE ALL WITH FRAME Frame1.
      WAIT-FOR CHOOSE of btn-Exit. 

These notes help to explain the code:

  1. Note that the initial definition of the selection list does not include the LIST-ITEMS.
  2. By using DEFAULT-ACTION, the fields in the form do not update until the user double-clicks a list item or presses RETURN or SPACEBAR. The FIND statement, which you’ll learn about in the next chapter, accesses the appropriate sales representative record.
  3. Since the names in the Salesrep table may contain commas, you have to set the LIST-ITEM delimiter to some character that won’t be in the data. You choose the asterisk.
  4. The FOR EACH block cycles through each record in the Salesrep table.
  5. The ADD-LAST( ) method adds the current Salesrep name to the bottom of the list. Since the SORT option is also employed, Progress will sort the list items before you display the widget.
  6. This FIND statement accesses a record so that some data appears at startup.
NOTE: Keep in mind that ToolTip information can be added to any selection list widget. Refer to the code examples in either the Toggle Box Programming Example or the Radio Set Programming Example presented earlier in this chapter that show how to define the TOOLTIP option.


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