Progress
Programming
Handbook


Attributes and Methods

At run time, a procedure can set or query combo box attributes to accomplish the following:

In addition to attributes, the combo box also supports list manipulation methods that allow a procedure to:

For example, the following procedure reads filenames into a combo box and uses the LIST–ITEMS attribute to change the contents of the list dynamically. To compare it with a similar procedure using a selection list, see the p-sel2.p procedure in the "Selection Lists" section.

p-combo2.p
DEFINE STREAM dirlist.
DEFINE VARIABLE ok-status AS LOGICAL.
DEFINE VARIABLE f-name AS CHARACTER FORMAT "x(14)".
DEFINE VARIABLE list-contents AS CHARACTER FORMAT "x(200)".
DEFINE VARIABLE dir AS CHARACTER FORMAT "x(40)".
DEFINE VARIABLE flcombo AS CHARACTER FORMAT "x(15)"
                VIEW-AS COMBO-BOX INNER-LINES 10 SORT.
FORM
   "Directory Pathname:"  SKIP
   dir AT 3 SKIP
   "Filename:" SKIP
   flcombo  AT 3
   WITH FRAME sel-frame NO-LABELS TITLE "File Selector".

FORM
   Readable AS LOGICAL Writable AS LOGICAL
   WITH FRAME file-status SIDE-LABELS.
   
ON GO, MOUSE-SELECT-DBLCLICK, RETURN OF dir
   DO:
      ASSIGN dir.
      RUN build-list.
   END.

ON VALUE-CHANGED OF flcombo
   DO:
       FILE-INFO:FILENAME = dir + "/" + SELF:SCREEN-VALUE.
       IF INDEX(FILE-INFO:FILE-TYPE, "D") > 0
       THEN DO:
          HIDE FRAME file-status.
          dir = FILE-INFO:PATHNAME.
          RUN build-list.
          DISPLAY dir WITH FRAME sel-frame.
       END.
       ELSE DO:       
          ASSIGN Readable = (INDEX(FILE-INFO:FILE-TYPE, "R") > 0)
                 Writable = (INDEX(FILE-INFO:FILE-TYPE, "W") > 0)
              
          FRAME file-status:TITLE = "Attributes of " + SELF:SCREEN-VALUE.
          DISPLAY Readable Writable WITH FRAME file-status.
       END.
   END. 
dir = OS-GETENV("DLC").
DISPLAY dir WITH FRAME sel-frame.

ENABLE dir flcombo WITH FRAME sel-frame.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

PROCEDURE build-list:
   ok-status = SESSION:SET-WAIT-STATE("General").

   INPUT STREAM dirlist FROM OS-DIR (dir).

   IMPORT STREAM dirlist f-name.
   list-contents = f-name.
   REPEAT:
      IMPORT STREAM dirlist f-name.
      list-contents = list-contents + flcombo:DELIMITER IN FRAME sel-frame
                      + f-name.
   END.
   INPUT CLOSE.

   flcombo:LIST-ITEMS IN FRAME sel-frame = list-contents.
   ok-status = SESSION:SET-WAIT-STATE("").
END PROCEDURE. 

This code allows you to select from a combo box of all the files and subdirectories within the specified directory. The DLC directory is the initial directory.

When you double click, press RETURN, or press GO on the Directory Pathname field, the procedure builds a list of the files in the combo box from the specified directory. When you select a new item in the list, the VALUE–CHANGED trigger executes. If the item is a file, the trigger displays your access to that file. If the item is a directory, the trigger rebuilds the combo box with the contents of that directory.

Note that within the internal procedure, build–list, the list of file and directory names is built first, and then the LIST–ITEMS attribute is used to change the contents of the combo box. You could use the ADD–LAST( ) method within the REPEAT loop to add items to the combo box one at a time, but using LIST–ITEMS once is more efficient. Note, also, the use of the DELIMITER attribute to ensure that the list is built using the current list delimiter.

For more information on each attribute and method, see the Progress Language Reference .


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