TrFile_SetDefaultType (function reference)

By January 1, 2021January 26th, 2021Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_SetDefaultType
Troi File Plug-in for FileMaker Pro


Sets the fileTypes to be displayed when showing SelectFileDialog. Also sets the default file type when creating new files.

SyntaxFunction badge

TrFile_SetDefaultType ( switches ; fileTypes )


switches not used, reserved for future use. Leave blank or put "-Unused"
fileTypes determine which files are shown. Also the first will be used when creating a file


If no fileType is specified, the TrFile_SelectFileDialog function will display all files.

The fileTypes parameter must be formatted in pairs of lines. You can specify multiple pairs of lines. The first line of the pair should contain a description of the files to be shown in the dialog. For example: “Text Files (*.txt)”. This is only visible on Windows.
The second line of the pair should contain the extension to be selectable. For example: “*.txt”. Also in the second line you can use multiple extensions to filter on by separating them with a semi-colon “;”. For example: “*.txt;*.doc”.

Returned Result

Data type returned



This function does not return anything at the moment. This may change in a future version.

Originated in

Troi File Plug-in 1.0


FileMaker Pro 16 to 19


See also the function “TrFile_CreateFile” to create a new empty file.
New with v8.0: the format of the filter parameter is now the same on macOS and on Windows!


This example will initially show files with the extensions .fmp12 and .fp7 (line 1 and 2). The user can change the popup to only show JPEG files (line 3 and 4) or to show all files (line 5 and 6).

Set Variable [ dontCare ; TrFile_SetDefaultType ( "-Unused "; 
          "FileMaker Pro files ( *.fmp12 ; *.fp7 ) ¶" &
          "*.fmp12;*.fp7¶" & 
          "JPEG ( *.jpg;*.jpe;*.jpeg ) ¶" &
          "*.jpg;*.jpe;*.jpeg¶"  & 
          "All files ( *.* ) ¶" &
          "*.*" ) ]
Set Field [ MyFileName ; TrFile_SelectFileDialog ( "-Unused" ; "Please choose a file" ) ]

TIP The * means 1 or more characters. On Windows only, if you use “a*.*” you can even filter on all filenames starting with the letter a. You an also limit to a specific file name, for example “project1.doc”. This will only let users select files named “project1.doc”.

Example 2

This shows creating a file with a Creator and FileType, NOTE that Creator and FileType are phased out on Mac OS, but you can still set them. On Windows the Creator/FileType are ignored.

We assume that in your FileMaker file the following fields are defined:

  gErrorCode		Global, number
  gFilePath		Global, text
  textField		text

gFilePath should contain the path to an existing file, for example “D:\Hello.TXT” (Windows) or “Disk1:Hello” (Mac OS). TextField contains the text you want to write. In a script add the following script steps:

Set Field [ gErrorCode ; TrFile_SetDefaultFileSpec ( gFilePath ) ]
Set Field [ gErrorCode ; TrFile_SetDefaultCreator ( "ttxt" ) ]
Set Field [ gErrorCode ; TrFile_SetDefaultType ( "TEXT" ) ]
Set Field [ gErrorCode ; TrFile_SetContents ( "-Encoding=ASCII_Windows" ; textField ) ]

This will set the default file to your file with a TextEdit FileType and Creator. Then the text is written to the file.

Used in example file


Related functionsFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_SetDefaultType (filep4281) 2021-0126 11:02:43