Get File Contents with Dialog
Shows the user a file selection dialog, the contents of the selected file is returned.
Get File Contents with Dialog [ Select ; Result ; Prompt ; Initial folder ; Encoding ; Convert to FileMaker line endings ]
|Select entire contents||replaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field|
|Result||the characters of the file the user selected. If the user pressed cancel an error code "$$-1" is returned|
|Prompt||(optional) adds a prompt text to the dialog. It may be left empty|
|Initial folder||(optional) the path to the folder where the dialog initially starts|
|Encoding||the desired character encoding, like UTF-8|
|Convert to FileMaker line endings||this will convert any line breaks in the data to the line break FileMaker expects: CRLF, LF and CR will all become CR|
Data type returned
The characters of the file the user selected. If the user pressed cancel an error code “$$-1” is returned.
Troi File Plug-in 9.0
FileMaker Pro 16 to 19
You can read up to 2 Gb into a field. However more than 500000 characters will slow down FileMaker considerably.
Only use “Convert to FileMaker Line endings” for getting text files, as it might change the data returned. If for example you use it with an image file the imported image might get corrupted.
On Mac the dialog will filter and show only text files by default. To change the default filtering use the TrFile_SetDefaultType function, or take a look at “Filtering Files” in the example databases.
Get File Contents with Dialog [ Select ; $Result ; "Please select the text file you want to use:" ; "D:\DataFiles\" ]
You can also use a calculation for the prompt, for example this one which uses a global text field:
Get File Contents with Dialog [ Select ; $Result ; "Please select the Excel file \"" & gFileName & "\"":" ]
This will result in a file selection dialog with this prompt text:
‘Please select the Excel file “invoices99.xls”:’.
Related script step
|Show Select File Dialog|