Creates a new empty file in the location indicated by the filePath.
Create File [ Select ; Result (error) ; FilePath ; Create Folders ]
|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 (error)||an error code|
|FilePath||the path to the file to create|
|Create Folders||off/on: also create new folders if they don’t exist in the specified path|
Data type returned
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:
|0||no error||The file was created|
|$$-48||dupFNErr||Destination file already exists|
|$$-1||genericErr||The file could not be created|
Other errors may be returned.
Troi File Plug-in 9.0
FileMaker Pro 16 to 19
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.
Starting with Troi File Plug-in 12.0 you can omit filemac: or filewin: too! Any path starting with a slash will be parsed as a FileMaker style path (of the platform FileMaker is running).
See also the script step: Show Save File Dialog to get a filepath for the file.
Create File [ Select ; gErrorCode ; "C:\Testtext.txt" ]
This will create the empty file “Testtext.txt” on the C disk.
Create File [ Select ; $ErrorCode ; "/macHD/users/ad/nw/foldB/myfile.log" ; Create Folders: on ]
This will create the empty file “myfile.log”. With “Create Folders” set to “on” this will also create new folders if they don’t exist in the specified path, for example the folders “nw” and “foldB” may be created.
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 steps
|Append to File|
|Insert in File|
|Set Contents of File|
|Show Save File Dialog|