Returns true if this file is not in exclusive use by a different application and is not locked.
TrFile_IsFree ( switches ; filePath )
|switches||not used, reserved for future use. Leave blank or put "-Unused"|
|filePath||the path to the file for which you want to know if it is free|
Data type returned
The returned result is a boolean: the function returns 1 if the file is free.
The returned result is 0 if the file is in exclusive use by a different application or is locked.
Note that an error code might be returned instead. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:
|$$-43||fnfErr||File not found, check if the path is valid|
Other errors may be returned.
Troi File Plug-in 11.0
FileMaker Pro 16 to 19
Note that some applications do not need to claim a file for exclusive use and will only read the file into their memory (and later write a modified version over the original file). If this is the case the TrFile_IsFree function will always return 1 (is free).
Set Field [ isFree ; TrFile_IsFree ( "-Unused" ; "C:\Test.xls" ) ]
This will return 0 if Excel has opened this file.
We assume that in your FileMaker file the following field is defined:
gFilePath Global, text
gFilePath should contain the path to the file of which you want to test if it is free, for example “D:\Data\NewReport.doc” (Windows) or “Mac HD:Data:NewReport.doc” (macOS).
In a script add the following script steps:
Set Variable [ $FilePath ; gFilePath ] If [ TrFile_IsFree ( "-Unused" ; $FilePath ) ] # ... do your stuff here, for example import the file into your database. Else # ... do your error handling here... End if
Used in example file