Progress
Programming
Handbook


Attributes and Methods

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

In addition to attributes, the selection list also supports methods that allow a procedure to:

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

p-sel2.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 sl AS CHARACTER VIEW-AS SELECTION-LIST
          INNER-CHARS 15 INNER-LINES 10 SORT SCROLLBAR-VERTICAL.
FORM
   "Directory Pathname:"  SKIP
   dir AT 3 SKIP
   "Filename:" SKIP
   sl  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 OF dir
   DO:
      ASSIGN dir.
      RUN build-list.
   END.

ON DEFAULT-ACTION OF sl
   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.
RUN build-list.

ENABLE dir sl 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 + "," + f-name.
   END.
   INPUT CLOSE.

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

This code allows you to select from a selection list of all the files and subdirectories within the specified directory. The DLC directory is the initial directory. The following screen appears:

When you double-click on an item in the list (or press RETURN in character mode), the DEFAULT–ACTION 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 selection list 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 method is used to change the contents of the selection list. You could use the ADD–LAST( ) method within the REPEAT loop to add items to the selection list one at a time, but using LIST–ITEMS once is more efficient.

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