use AppleScript version "2.4"
use scripting additions
set f to POSIX file "/private/var/folders/ty/mwzg13z57q70ssdstzn7r5lm0000gn/T/TemporaryItems/SSLG_tempfile.txt"
set fh to open for access f -->587
set t to read fh from 1 -->"no"
close access fh
open f --> document opens containing the text
What is going on here?
The file’s contents are 7224 characters of plaintext that do not even contain “no”. The file handle forms properly, but the read command just returns attitude!
Something weird with encoding or the BOM? What happens if you read as UTF-8, or without using the from
position?
Post the first 100 characters of the file. Also is the file UTF8 or UTF16?
Sorry for abandoning the topic for a bit. Thanks for the responses…
file -I /private/var/folders/ty/mwzg13z57q70ssdstzn7r5lm0000gn/T/TemporaryItems/SSLG_tempfile.txt
→ SSLG_tempfile.txt: text/plain; charset=us-ascii
Using “from” or not using “from” as «class utf8»
→ same
@robertfern
→ I would if I could. It’s just plaintext but confidential. I wrote plaintext Lorem Ipsum to the file and had the same error. It wasn’t the character set.
I’ve read this file (technically the file is created, written, appended, read, and then destroyed at the end of the script) 100s of times from the same code without issue. Then suddenly I began having this issue. I made no changes to the code that creates, reads or writes the file.
I resolved this by generating the file with a unique filename on each creation. No further info on what the cause of the error-with-attitude was. Problem resolved. Moving on.