---
url: >-
  /statelake/scripting-reference/functions-and-procedures/file-functions/filelocked.md
---

# FileLocked

**FileLocked** returns **True** if the file specified by **aFilePath** is locked.

Depending on the program, a file may or may not be locked once opened, to maintain a form of version control and to mitigate any saving conflict.

Use this function to indicate whether another program is accessing the file in a manner that does not allow sharing.

**Declaration**: Function FileLocked(aFilePath : string) : boolean

An example.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  ConfYN : boolean;
begin
 if FileLocked(Source.FileCon.CurrentFilename) then
    LogWarning('The file is locked,')
 else
    LogWarning('All OK.');

  ConfYN := FileLocked('C:\Test\GardenColours.docx');
 If ConfYN = true then
    LogInfo('Yes the file is currently locked and in use.')
 else
    LogInfo('The file is currently unlocked and able to be used.');

  LogInfo('');
end;
```
