Reference > Script steps reference > Files script steps > Create Data File
 

Create Data File

Creates an empty, closed data file, to then open with the Open Data File script step and add data to using the Write to Data File script step.

See also 

Options 

Specify File is the path of the data file to create. See Creating file paths.

Create folders specifies whether to create new folders if they don't exist in the specified path.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

No 

FileMaker Server 

Yes 

FileMaker Cloud products 

Yes 

FileMaker Data API 

No 

Custom Web Publishing 

Yes 

Runtime solution 

No 

Originated in 

FileMaker Pro 18.0 Advanced

Notes 

If the specified path can't be accessed or the file already exists, Get(LastError) returns 300 ("File is locked or in use"). See Get File Exists script step.

Example 1 

Creates an empty data file named data.txt if the path already exists.

Create Data File [ "data.txt" ; Create folders: Off ]

Example 2 

Checks whether a file named change.log exists in the Documents folder and, if it doesn't, creates the file. If the file can't be created, the script displays an error code.

Set Error Capture [ On ]
Set Variable [ $file ; Value: Get ( DocumentsPath ) & "change.log" ]
Get File Exists [ "$file" ; Target: $fileExists ]
If [ $fileExists ]
Show Custom Dialog [ $file & ": Already exists" ]
Exit Script [ Text Result: ]
End If
Create Data File [ "$file" ; Create folders: Off ]
Set Variable [ $error = Get ( LastError ) ]
If [ $error = 0 ]
Show Custom Dialog [ $file & ": Created" ]
Else
Show Custom Dialog [ $file & ": Not created. Error code: " & Get ( LastError) ]
End If

Related topics 

Open Data File script step

Script steps reference (alphabetical list)

Script steps reference (category list)