I am trying to use the oath returned from a save panel but it keeps causing errors.
The path returned of the save panel is some thing like “Users/Sharky/Desktop/Test.txt” but when I try to use this as is with an ‘open for access’ command, I get a ‘bad file name’ error. I could fix the slashes in the path with TIDs but should I have to and would that make any difference?
Any guidance n using the 'save panel" to dictate the save path for write to file command would be great.
wrong path syntax is one of the most common errors (and misunderstandings) in AppleScript.
The save panel handler returns a POSIX path (/) but plain AppleScript (and also the read/write commands) works only with HFS paths (:).
You have to coerce the POSIX path to a HFS path like this
set targetFile to "Users/Sharky/Desktop/Test.txt" as POSIX file
set ff to open for access targetFile with write permission
.