Test if file exists

Command group Flag affected Reversible Execute on client Platform(s)
Operating system YES NO NO All


Test if file exists {file-name}


This command tests if the specified file exists and can be opened. The flag is set if the file exists and can be opened. Otherwise, it is cleared. You can use this command to prevent the user from overwriting existing files with print files, and so on. To perform the test, the command opens the file in shared read mode, and then closes it, if the open was successful.

To just test for the existence of a file, without opening it, use the Fileops function FileOps.$doesfileexist.

You cannot use this command to check for the existence of a data file if the data file is in use by another workstation. Use Open data file for this type of checking.

You can use this command to test for the existence of a data file that is to be accessed using the ODB (Omnis Data Bridge). Specify the location of the file using the ODB syntax:

where address:port is the TCP/IP address and port number of the ODB server, e.g., and name is the name of a data file accessed using the ODB server. You can omit address:port:, in which case Omnis uses the address and port stored in the $odbserver root preference. Note that the value of $odbserver is stored in the file odb.txt in the studio folder of the Omnis installation tree.


; If the file myfile already exists in the root
; of the studio tree show a ok message
Calculate lPath as con(sys(115),'myfile')
Test if file exists {[lPath]}
If flag true
  OK message {The file [lPath] already exists}
  Create file ([lPath])
End If