Script OPEN Statement

OPEN [<file name>] [ {/R | /W} ]

The OPEN statement is used to open a new or existing file from within a script.

The file name is optional. If no file name is supplied, you are prompted to enter one.

The file name can be a  full path, such as C:\Docs\Project2\data.txt, or a simple name, such as data.txt. If it is a simple file name, the file is opened in the Uscripts folder.

The /R option opens the file to read only. The /W option allows both reading and writing in the file. The default option is /W.

All data written to the file is appended to the end of the file. To rewrite a file completely, delete it before opening it.

For example:

_error = "Command timed out. Error ##36."
DELETE <errors.txt>   \* Delete errors.txt from Uscripts
OPEN <errors.txt>     \* Open (and create) file in Uscripts
WRITE _error

places the following message in a file named errors.txt:

Command timed out. Error #36.

If an error occurs, the _$filerror system variable is non-zero.

Copyright © 2017 American Chemical Society. All Rights Reserved.