Skip to main content

TrFile_SelectFileDialog (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_SelectFileDialog
Troi File Plug-in for FileMaker Pro

TrFile_SelectFileDialog

Presents the user with a standard dialog and displays all files in a directory.

SyntaxFunction badge

TrFile_SelectFileDialog ( switches ; prompt ; { initialFolder } )

Parameters

switches modifies the behavior of the function
prompt the prompt that will be displayed to tell the user which file to select
initialFolder (optional) the file path to the folder where the dialog initially starts

Switches

Switches can be:

-SelectDefault (macOS) select the default location. the initial folder appears as the current selection
-SelectPackages (macOS) allow selection of macOS packages, like application packages
-OpenPackages (macOS) allow macOS packages, like application packages, to be opened and navigated
-HideInvisibles hides invisible files in the selection dialog
-AllowMultipleFiles allow the user to select multiple files in the dialog
-DontResolveAlias when you select an alias/shortcut the result is the path to the alias itself
-AllowNonLocalCloudItems allows you to select files on iCloud that are not downloaded to the local disk

The following switch no longer works (on macOS):

-ReturnFSSpec deprecated! the function no longer returns the folder as a FSSpec instead of a full path

Returned Result

Data type returned

Text

Result

The function returns a fullpath for the selected file to be used with one of the file manipulation functions.

If the user cancels an error code of “$$-1” is returned.

Originated in

Troi File Plug-in 1.2

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

Filtering on macOS is now the same as on Windows. To change the default filtering see the TrFile_SetDefaultType function, or take a look at “Filtering Files” in the example databases.

NOTE: macOS packages, like application packages, are actually folders, so this will return a path to a folder!

When the switch “-AllowMultipleFiles” is added, you can use the Command key on macOS or the Control + Alt key on Windows to select or deselect extra items. To select a contiguous group of files at once, click on the first file, then hold Shift and click the last one and all files are selected.
Each selected file is returned on a new line.

v13.0 added the switch “-AllowNonLocalCloudItems”

Example

On Mac OS:

Set Field [ MyFileName ; TrFile_SelectFileDialog ( "-Unused" ; "Please choose a file to import" ; 
			"Mac HD:Solution Files:Import:" ) ] 

Set Field [ MyFileName ; TrFile_SelectFileDialog ( "-SelectPackages" ; "Please choose a file to import" ; 
			"Mac HD:Solution Files:Import:" ) ]

Or on Windows:

Set Field [ MyFileName ; TrFile_SelectFileDialog ( "-Unused" ;  "Please choose a file to import" ; 
			"C:\Solution Files\Import\" ) ]

This will start the selection at the folder “Import” in the “Solution Files” Folder.

It returns “HD Mac:Text files:My Letter” if the user selects that particular file on Mac OS. On Windows it may return “C:\Text files\My Letter”.

Used in example file

SelectFile.fmp12

Related functionsFunction badge

TrFile_SaveFileDialog
TrFile_SetDefaultType
TrFile_SetFileAttribute

Related script stepScript step badge

Show Select File Dialog

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_SelectFileDialog (filep4271) 2024-0604 19:31:02