Home > Language Reference > File Functions > Exist

Exist

The Exist function checks for the existence of the specified file.

Usage

Before processing actions on a file, it is a good practise to test first if the file exists. You will not get an error if in some circumstances, the file does not exist.

Syntax

ret=Exist(<filename>)

Parameters

<filename>, string, name of the file to test. If no path is included in <filename>, the file is searched in the current working folder.

Return value

ret, integer. If <filename> exists, the return value is 1. If not, the return value is 0. 

See also

ExistDir

Example

'Test if a program exists under Windows folder before launching it
a=Exist(WinDir$()+"\sol.exe")
If a = 1 then    
    shell("sol.exe")
EndIf