Files on your computer’s disk can be accessed using a traditional “programming” approach with the file access commands (
read from file, etc.). However, for quick and easy access to the contents of a file, a script may simply access the file directly as a container, without the need for opening or closing it.
put file "/tmp/myFile" into fileContents
To treat a file as a container, simply refer to the file using the syntax file filename, at any point in a script where you would use a variable name. Here filename may be either the full pathname of the file, or its local name relative to the current working folder (or a variable or expression that yields its full or relative name). The text contained within the file is its value. When a script puts something into a file, the changed text will appear in the file on the disk when that file is next accessed.
A text value stored into a file is permanent — it is saved on the disk automatically. So be careful in how you use this feature — a single
set command can wipe out the entire contents of an existing file.