Skip to main content

TrFile_IsFree (function reference)

Troi File Plug-in for FileMaker Pro

TrFile_IsFree

Returns true if this file is not in exclusive use by a different application and is not locked.

SyntaxFunction badge

TrFile_IsFree ( switches ; filePath )

Parameters

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

Returned Result

Data type returned

Number

Result

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.

Originated in

Troi File Plug-in 11.0

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

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).

Example

Set Field [ isFree ; TrFile_IsFree ( "-Unused" ;  "C:\Test.xls" ) ]

This will return 0 if Excel has opened this file.

Example 2

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

Attribute.fmp12

Related functionsFunction badge

TrFile_Exists
TrFile_GetFileAttribute

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 2023 –> TrFile_IsFree (filep4322) 2023-0601 15:44:20