file browser
Support Library
This function provides interactive file browsing (using the table features of table view()) where
the user will see directory and file names, file type, size and date and timestamp of last modification.
Optionally, the different file types appear in their characteristic colors, e.g. blue for (Microsoft Word) documents.
While browing the files, following navigation keys are available:
Key | Function |
---|---|
↑ | Move up |
↓ | Move down |
← | Move left |
→ | Move right |
Pg up | 1 screen page up |
Pg dn | 1 screen page down |
Home | Move to 1st column |
End | Move to last column |
Ctrl-Home | Move to 1st row |
Ctrl-End | Move to last row |
Ctrl- ↑ | Reduce number of screen lines to display contents |
Ctrl- ↓ | Increase number of screen lines to display contents |
Ctrl- ← | Reduce column width |
Ctrl- → | Increase column width |
Ctrl-C | Copy cell contents into clipboard (Pushing Ctrl-C twice in a row stops program execution) |
F1 | Quick on-screen help for the available navigation functions |
Enter key | Enter a sub-folder or, on the 1st row, the parent folder (..) |
Escape key | Stop program execution |
Visible characters | Specify a path or directory name directly to change directory. Just start typing and a prompt to choose a directory will occur automatically. |
Hint: Use the drag and drop feature. If you have a file browser open, then click on the folder symbol to choose, hold the mouse key pressed and drop it into the console with the running B4P program. The drop action actually types the full path of the selected directory. Press 'Enter' to change the directory. If the directory cannot be found or is not accessible, then no change takes place.
Under normal conditions, the 'Support Library' is loaded automatically, so no 'include(...)' call is needed.
Not suitable for batch processing
1-4
No. | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Opt. 1 input |
string | Prompt The prompt text will be displayed at the bottom of the table. UNICODE PUA2 characters (like &yellow; for yellow texdt) are allowed here to add visual effects.
| ||||||||||||||||
Opt. 2 input |
string | Path Specify an existing path. Relative paths such as specifying subdirectories, '..' for parent folder, '.' for current folder, etc. are supported. Wildcards are not allowed here. Default value: . (current folder) | ||||||||||||||||
Opt. 3 input |
string | Pattern Specify the pattern to be applied for the file names. Folder names are not affected by this.
For exapmle, specify "*.xlsx,*.xlsm" to include all Excel files with and without macros.
| ||||||||||||||||
Opt. 4. input |
set | Options The parameters set may contain the following options.
Following options, also provided in table view(), are also supported here:
Default value: {} (empty set) - No options specified |
Type | Description |
---|---|
string | Chosen file An empty string (blank) is returned if the file browser is left by pressing 'Escape'. If 'Enter' is pressed on a file name, then one of the following cases apply: * If the 4th funtion parameter contains 'files only' as a setting which disables navigation through directories, then only the file name will be returned. * Otherwise, the full path with the file name will be returned. |
file name[] = file browser( "Select an Excel file: ", ".", "*.xlsx,*.xlsm", { colors, file names ignore case } );
echo("Good job. The chosen file name is: ", file name[] );