file ... exists

operator

Return type:
Switch
Returns:
True if the system path named by the string expression exists, and false otherwise.
Syntax
file string-expression exists
    


Purpose

The file ... exists test is used to determine if the system path named by the string expression exists. This is useful to avoid a program error when reading a file, or to avoid overwriting an existing file.

For example, the following program shows how file ... exists test is used to avoid overwriting the file errors.log:

  process
     local stream errors
  
     assert !(file "errors.log" exists) 
            message "File errors.log already exists. Please delete or rename it before running this program."
  
     open errors as file "errors.log"