Name

write — write data

Description

Writes data to a file, optionally coercing the data to a desired datatype. There are options for where to start and how much data to write.

The data coercion options for reading and writing allow you to store any kind of data in a text file and retrieve it later. The data is encoded, but it will be decoded correctly if you specify the same class when writing and when reading.

Example

        open for access f with write permission
        write {"Mannie", "Moe", "Jack"} as list to f
        close access f
        open for access f
        set L to read f as list
        close access f
        L -- {"Mannie", "Moe", "Jack"}

On the whole, however, this approach is not very flexible; see Section 9.6.2.

Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.