FileOps.$getfilename()

Function groupExecute on clientPlatform(s)
FileOpsNOAll

Syntax

FileOps.$getfilename(&vListOrCharacter[,cPrompt,cFilter,cInitialDirectory,iFlags])

Description

Opens the standard Open file dialog. Returns Boolean true if a file was selected

You can specify the dialog title in cPrompt, and restrict the files displayed using a filter passed in cFilter. The filter comprises one or more entries separated by the vertical bar character '|'. Each filter entry has two components, again separated by a vertical bar. The filter entries populate the file-type selection dropdown or popup list. The first component of an entry is the text to display in the dropdown or popup list. The second component is a file-matching specification. On all platforms, a file-matching specification can have the form *.<ext>, to match all files with the extension <ext>, or *.* to match all files. On macOS, a file-matching specification can also have the form TYPE or TYPE,CREATOR, where TYPE and CREATOR are the 4 character, case-sensitive Mac file type and creator. Example cFilter parameters:

Text files|*.txt Matched all files with .txt as their extension
Text files|*.txt|Omnis Libraries|OO$A,OO$$ The first entry matches all files with .txt as their extension. The second entry matches all Omnis Studio libraries used under macOS.

You can also specify the initial directory for the Open dialog in cInitialDirectory.

The iAppflags parameter only applies when running on macOS. It is optional; if specified, it must be a combination of the following constants:

kFileOpsSelectApps Allows applications to be selectable within the dialog
kFileOpsOpenApps Allows the dialog to browse the content of applications

Note that kFileOpsOpenApps automatically implies kFileOpsSelectApps, although it is valid to specify both flags (kFileOpsSelectApps + kFileOpsOpenApps).

The name and full path of the file selected by the user is returned in the cPath parameter. Note that the file is not open: you must do something with the file name and path returned.

The cPath parameter can be either a Character variable to return a single file, or a list to allow the user to select more than one file. When cPath is a Character variable the function returns a single file name and path. Note that the file selected is not opened: you must do something with the file name and path returned.

When cPath is a List variable, FileOps will allow the user to select more than one file in the select file dialog and return the path of the selected files into a list with a single column 'name' which is created automatically. Note that when cPath is a list, if the user selects a single file, FileOps will return a list with a single line.

Note that if the file selected is an alias/shortcut/link, then the returned value is the result of resolving the alias/shortcut/link to its target, not the path of the alias/shortcut/link.

$getfilename() returns true if the user selected a file and pressed OK. Otherwise, it returns false, meaning that the user pressed Cancel.

 

Example

Do
 
FileOps
.
$getfilename
(
lPath
,
'Please locate the Omnis help file'
,
'Help files|*.ohf'
,
con(
(
sys(
(115),
'help'
))
 
Returns 
lError

# returns the name and full path of the file selected, e.g. 'c:\omnis\help\omnis\omnis.ohf'