Skip to main content

Get File Contents with Dialog (script step reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Script steps reference > Get File Contents with Dialog
Troi File Plug-in for FileMaker Pro

Get File Contents with Dialog

Shows the user a file selection dialog, the contents of the selected file is returned.

SyntaxScript step badge

Get File Contents with Dialog [  Select ; Result ; Prompt ; Initial folder ;
                                Encoding ;
                                Convert to FileMaker line endings ]

Options

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

Returned Result

Data type returned

Text

Result

The characters of the file the user selected. If the user pressed cancel an error code “$$-1” is returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

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.

Example

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 stepScript step badge

Show Select File Dialog

Related functionsFunction badge

TrFile_ContentsDialog
TrFile_GetContents

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 2024 –> Get File Contents with Dialog (filep7202) 2024-0604 18:59:24