filebox
Displays a file selection box.
filebox{/save | /dir | /savenocheck} {Filter {,DefaultDirectory} }
Example: filebox "*.png;*.gif;*.jpg", "d:\images\"
Qualifiers
Qualifier | Description |
---|---|
/save | Allows the user to specify the name of a new file instead of an existing file |
/savenocheck | If the user specifies an existing file to save to, the file is overwritten without warnings or prompts about overwriting the file. |
/dir | Allows users to select a folder instead of a file. If the /dir switch is used, it is not possible to use the /save switch or to provide a filter. |
Parameters
Parameter | Data Type | Description |
---|---|---|
Filter | String | Restriction criteria that limit the files listed to a subset of those present in the directory. The Filter must be valid for the platform. |
DefaultDirectory | String | Default directory and, optionally, the
default file specification that is valid for the platform. For example,
"c:\dirname\" or "c:\*.bat" .If DefaultDirectory is omitted the first time filebox is called during a session, Uniface uses the directory in which the application was started. The next time DefaultDirectory is omitted, Uniface uses the directory that was selected or where the last selected file was located. |
Return Values
Value | Description |
---|---|
<0 |
An error occurred. $procerror contains the exact error. |
0
|
The user did not select a file |
1
|
The user selected a file. $result contains the fully qualified name of the file. |
Value | Error constant | Meaning |
---|---|---|
-16 through -30 | <UNETERR_*>
|
Errors during network I/O. |
-406 | <UMISERR_FILEBOX>
|
An error occurred during a filebox statement. |
Use
Use in Form components.
Description
The filebox statement displays a native GUI file selection box. If the application is running in character mode, a standard Uniface file selection box is displayed. The file selection box allows the user to select an existing file in a directory, or, if the /save option is used, to specify the name of a new file. The user can select only one file from the file selection box.
Filtering the Files Displayed
You can restrict the files displayed using a Filter. For example, using the following Filter means that only files with an .xml extension are initially displayed:
filebox "*.xml"
In character mode ($GUI=$CHR), assignments are also considered by the file selection box. For example, the following assignment would cause the character mode file selection box to initially display all export files from the directory h:\uniface\xml:
*/*.xml = h:\uniface\xml\*.xml
The use of wildcards in Filter is platform-dependent, though most platforms support common wildcards such as * and ?. If the native file selection box allows, the user can override the Filter provided; this is determined by the GUI in use. If the /save option is also used, Filter provides the default file extension, if none is supplied by the user.
On Microsoft Windows:
- You can specify multiple file types in
Filter by using the Uniface subfield separator GOLD ;
(
;
) to delimit the values. For example:filebox "*.exp;*.xml", "c:\tmp\"
- You can add a description to the filter by
using the following syntax: Filter=Description. For
example:
filebox "*.json=JSON Files", "D:\work\uniface\"
Changing the Dialog Text for file/dir
By default, the dialog box displayed by
filebox/dir contains the text Choose a folder
. You can remove
this or change this to your preferred text and language by editing the Uniface message text
4805
.
Setting the Default Path
If DefaultDirectory names a directory, it must end with the path separator for the platform, for example, "c:\tmp\" on Microsoft Windows.
If the native file selection box supports it, the user can override the DefaultDirectory provided; this is determined by the GUI in use.
The following example displays a file selection box in which all files with a .xml extension are listed:
filebox "*.xml"
The following example displays a file selection box under Microsoft Windows that lists all files with a .p* extension, where the default directory is h:\home\uniface\prints :
filebox "*.p*", "h:\home\uniface\prints\"