openFile
Displays a file dialog window to let the user select a single file path on the local file system.
Syntax
ui.Interface.frontCall("standard", "openFile",
[path,name,wildcards,caption],
[result])
- path - The initial directory path to look for files. On some platforms, when path is a filename like "/tmp/document.txt", the name of the file is used as default file to be selected.
- name - The label to be displayed for the file types / wildcards.
- wildcards - A space-separated list of wildcards (for example: "*.pdf" or "README* test*.txt")
- caption - The caption of the file dialog window / frame.
- result - The name of the selected file (or
NULL
if canceled).
Usage
When invoking the "openFile
" front call, the front-end displays a file dialog
window using the local file system, to let the end user select an existing file.
Note: The file dialog window rendering and features depend on the type of
front end and the type of the front end platform (desktop OS, web browser).
If the user cancels the dialog, the front call returns NULL
in the result variable.
Important: With the GBC front-end in a web browser,
the path parameter is ignored, and wildcards can
only hold one type of file extension.
Tip: When specifying a file path, pay attention to platform specific
rules regarding directory separators and space characters in file names. When the front-end executes
on a recent Microsoft™ Windows™ system, you can use the
/
slash character as directory separator,
like on Unix systems. A directory or file name can contain spaces, and there is no need to surround
the path with double quotes in such case. When using backslash directory separators, make sure to
escape backslash characters in string literals with \\
.Example
MAIN
DEFINE rec RECORD
path STRING,
name STRING,
wildcards STRING,
caption STRING
END RECORD
DEFINE result STRING
LET rec.path = "/tmp"
LET rec.name = "Image files"
LET rec.wildcards = "*.jpg *.png"
LET rec.caption = "Open file"
CALL ui.Interface.frontCall("standard","openFile",[rec.*],[result])
IF result IS NULL THEN
DISPLAY "No file was selected."
ELSE
DISPLAY "File :", result
END IF
END MAIN