TrFile_CreateFile (function reference)

Troi File Plug-in > Functions reference > TrFile_CreateFile
Troi File Plug-in for FileMaker Pro

TrFile_CreateFile

Creates a new empty file in the location indicated by the filePath. This function requires no user intervention.

SyntaxFunction badge

TrFile_CreateFile( switches ; filePath )

Parameters

switchesreserved for future use, leave empty or set to "-Unused"
filePaththe path to the file to create

Returned Result

Data type returned

Error code

Result

The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

0no errorThe file was created
$$-48dupFNErrDestination file already exists
$$-1genericErrThe file could not created

Other errors may be returned.

Originated in

Troi File Plug-in 1.0

Compatibility

FileMaker Pro 12 to 16

Considerations

NEW you can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.
See also the function TrFile_SaveFileDialog to get a filepath for the file.

Example

Set Field[ gErrorCode ; TrFile_CreateFile( "-Unused" ; "C:\Testtext.txt" ) ]

This will create the empty file “Testtext.txt” on the C disk.

Example 2

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

  gErrorCode		Global, number
  gDestFilePath		Global, text 

gDestFilePath should contain the path to the destination and should not exist, for example “D:\Logs\L2000_01.TXT” (Windows) or “Mac HD:Logs:Log 2000_01” (Mac). In a script add the following scriptstep:

Set Field[ gErrorCode ; TrFile_CreateFile( "-Unused" ; gDestFilePath ) ]

This will create the file indicated in the gDestFilePath.

Related functionsFunction badge

TrFile_DeleteFile
TrFile_SetContents
TrFile_SetDefaultCreator
TrFile_SetDefaultType

Related script stepScript step badge

Create File

Online Help Page for Troi File Plug-in for 12 to 16 –> TrFile_CreateFile (filep4211) 2017-0513 17:32:27