DirList
PowerScript function
Description
Populates a ListBox with a list of files. You can specify a path, a
mask, and a file type to restrict the set of files displayed. If the
window has an associated StaticText control, DirList can display the
current drive and directory as well.
Applies to
ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox
controls
Syntax
|
1 |
listboxname.DirList ( filespec, filetype {, statictext } ) |
|
Argument |
Description |
|---|---|
|
listboxname |
The name of the ListBox control you want to |
|
filespec |
A string whose value is the file pattern. This is usually |
|
filetype |
An unsigned integer representing one or more types of
To list several types, add the numbers associated with the |
|
statictext (optional) |
The name of the StaticText in which you want to display |
Return value
Boolean.
Returns true if the search path is valid so that the ListBox is
populated or the list is empty. DirList returns false if the ListBox
cannot be populated (for example, filespec is a file, not a directory, or
specifies an invalid path). If any argument’s value is null, DirList
returns null.
Usage
You can call DirList when the window opens to populate the list
initially. You should also call DirList in the script for the
SelectionChanged event to repopulate the list box based on the new
selection. (See the example in DirSelect.)
Alternatives
Although DirList’s features allow you to emulate the standard File
Open and File Save windows, you can get the full functionality of these
standard windows by calling GetFileOpenName and GetFileSaveName instead
of DirList.
Examples
This statement populates the ListBox lb_emp with a list of
read/write files with the file extension TXT in the search path
C:EMPLOYEE*.TXT:
|
1 |
lb_emp.DirList("C:EMPLOYEE*.TXT", 0) |
This statement populates the ListBox lb_emp with a list of read-only
files with the file extension DOC in the search path C:EMPLOYEE*.DOC and
displays the path specification in the StaticText st_path:
|
1 |
lb_emp.DirList("C:EMPLOYEE*.DOC", 1, st_path) |
These statements in the script for a window Open event initialize a
ListBox to all files in the current directory that match *.TXT:
|
1 2 3 |
String s_filespec s_filespec = "*.TXT" lb_filelist.DirList(s_filespec, 16400, st_filepath) |
See also