TrFile_SetDefaultCreator (function reference)

By May 1, 2017May 20th, 2020Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_SetDefaultCreator
Troi File Plug-in for FileMaker Pro

TrFile_SetDefaultCreator

Specifies the file creator to be used when creating a new file. This creator will be used for subsequent calls to TrFile_CreateFile.

SyntaxFunction badge

TrFile_SetDefaultCreator ( switches ; Creator )

Parameters

switchesnot used, reserved for future use. Leave blank or put "-Unused"
CreatorThe Creator of a file is a 4 character code used to designate the application that created a file. For example: use "ttxt" to create a SimpleText text file

Returned Result

Data type returned

Error code

Result

This function returns an error code.

Originated in

Troi File Plug-in 1.0

Compatibility

FileMaker Pro 15 to 19

Considerations

See also the function “TrFile_CreateFile” to create a new empty file.
Mac only. Ignored on Windows.
Starting from v3.0.5: if you use “” as creator no creator is used for newly created files.

Example

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). TextField contains the text you want to write. In a script add the following scriptsteps:

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 SimpleText FileType and Creator. Then the text is written to the file.

Related functionsFunction badge

TrFile_CreateFile
TrFile_SetDefaultType

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 15 to 19 –> TrFile_SetDefaultCreator (filep4274) 2020-0520 18:08:39