DirSelect PowerScript function
Description
When a ListBox has been populated with the DirList function, DirSelect retrieves
the current selection and stores it in a string variable.
Controls
ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox controls
Syntax
|
1 |
<span>listboxname</span>.<span>DirSelect</span> ( <span>selection</span> ) |
|
Argument |
Description |
|---|---|
|
listboxname |
The name of the ListBox control from |
|
selection |
A string variable in which the selected |
Return Values
Boolean. Returns true if
the current selection is a drive letter or a directory name (which
can contain files and other directories) and false if
it is a file (indicating the user’s final choice). If any
argument’s value is null, DirSelect returns null.
Usage
Use DirSelect in the SelectionChanged event
to find out what the user chose. When the user’s selection
is a drive or directory, use the selection as a new directory specification
for DirList.
Examples
The following script for the SelectionChanged event
for the ListBox lb_FileList calls DirSelect to
test whether the user’s selection is a file. If not, the
script joins the directory name with the file pattern, and calls DirList to
populate the ListBox and display the current drive and directory
in the StaticText st_FilePath. If
the current selection is a file, other code processes the file name:
|
1 |
string ls_filename, ls_filespec = "*.TXT" |
|
1 |
|
1 |
IF lb_FileList.<span>DirSelect</span>(ls_filename) THEN |
|
1 |
//If ls_filename is not a file, |
|
1 |
//append directory to ls_filespec. |
|
1 |
ls_filename = ls_filename + ls_filespec |
|
1 |
lb_filelist.DirList(ls_filename, & |
|
1 |
16400, st_FilePath) |
|
1 |
ELSE |
|
1 |
... //Process the file. |
|
1 |
END IF |