Create File (script step reference)

By May 1, 2017 May 22nd, 2019 Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Create File

Creates a new empty file in the location indicated by the filePath.

SyntaxScript step badge

Create File [ Select ; Result (error) ; FilePath ]

Options

Select entire contentsreplaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Result (error)an error code
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 be created

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to 18

Considerations

You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.
See also the script step: Show Save File Dialog to get a filepath for the file.

Example

Create File [ Select ; gErrorCode ; "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 script step:

Create File [ Select ; $ErrorCode ; gDestFilePath ]

This will create the file indicated in the gDestFilePath, and store the error code in the variable $ErrorCode.

Related script stepsScript step badge

Append to File
Delete File
Insert in File
Set Contents of File
Show Save File Dialog

Related functionFunction badge

TrFile_CreateFile

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 14 to 18 –> Create File (filep7211) 2019-0522 16:30:34