Skip to main content

TrFile_IsFree (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
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 17 to FileMaker Pro 21 (2024)

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 17 to 2024 –> TrFile_IsFree (filep4322) 2024-0604 19:23:32

troi.com
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognizing you when you return to our website and helping us to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.