A function that can be used in Scripting.

Syntax and semantics

tryToAppendFile (filePath$)
check whether this file can be appended to.

The file is opened for appending, then closed (if the file already existed, it is not changed).

Return value

Upon success (i.e. the file already existed and can be appended to, or the file didn’t exist yet but was successfully created), this function returns 1 (true). Otherwise, the function returns 0 (false); this can happen if the folder in the path does not exist, or if the file is (or would be) on a read-only device.

For instance, if my TIMIT database is in a read-only disk image called TIMIT.dmg, and I mounted that disk image on my Mac (by double-clicking TIMIT.dmg), then trying

    tryToAppendFile ("/Volumes/TIMIT/readme.doc")

would return 0.

Related function

For a non-destructive version of this function, see tryToWriteFile.

Links to this page

© Paul Boersma 2023