FileExists Procedure

Returns whether a file exists at the given path and filename.
The user may not have permission to view files in the given path. In that case, false is returned even though the file may exist.
Warning: This function is easy to misuse. Keep in mind that other programs are running at the same time as your TMBASIC program. Another program may create/delete the file in between the call to FileExists and the subsequent read or write of the file. In computer programming this is called a time-of-check to time-of-use (TOCTOU) bug.
It is better to try performing the file operation without checking for file existence. Then, catch any ERR_FILE_NOT_FOUND errors.
Declaration
function FileExists(filePath as String) as Boolean

Parameters

Return value

Booleantrue if the file exists. false if the file does not exist, or if the user cannot access the path.

Example

Code
print FileExists("myfile.txt")
WriteFileText "myfile.txt", "Hello"
print FileExists("myfile.txt")
DeleteFile "myfile.txt"
print FileExists("myfile.txt")
Output
false
true
false