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.
Controls
ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox controls
Syntax
|
1 |
<span>listboxname</span>.<span>DirList</span> ( <span>filespec</span>, <span>filetype</span> {, <span>statictext</span> } ) |
|
Argument |
Description |
|---|---|
|
listboxname |
The name of the ListBox control you want |
|
filespec |
A string whose value is the file pattern. |
|
filetype |
An unsigned integer representing one
To list several types, add the numbers associated with the |
|
statictext (optional) |
The name of the StaticText in which you |
Return Values
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.<span>DirList</span>("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.<span>DirList</span>("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 |
String s_filespec |
|
1 |
s_filespec = "*.TXT" |
|
1 |
lb_filelist.<span>DirList</span>(s_filespec, 16400, st_filepath) |