Scripting Additions 'Read' has stopped reaching EOF?
Scripting Additions 'Read' has stopped reaching EOF?
- Subject: Scripting Additions 'Read' has stopped reaching EOF?
- From: Chap Harrison <email@hidden>
- Date: Sun, 25 Jan 2004 17:07:48 -0600
orders.txt is a raw ASCII file containing records, which contain fields.
The fields are delimited with fs (ASCII 28), and the records are
delimited with rs (ASCII 30). The fields may contain any typeable
ASCII characters, including newlines. There are no non-ASCII (>127)
bytes in the file.
*** top of file ***
111 f 22222 f 333333 f 44444 f 55555 f r
:
:
11111 f 22 f 333333 f f 55555 f r
*** end of file ***
f = ASCII 28, r = ASCII 30. Digits represent ASCII data.
I was successfully reading these records up until very recently! I've
done nothing to change the format of the ASCII file, nor do I *think*
I've touched anything in the Applescript that's involved with reading
each record from the file into an Applescript list.
Now, it reads okay up through the final record. On the next read,
instead of entering the 'on error' block indicating it's hit EOF, it
continues to return a portion of the final record!! And I'm using the
"right" delimiter characters for fs and rs now. Any ideas what
happened, or at least how to read dependably?
Thanks, Chap
-- begin script
property gParsePath : (path to (documents folder) from (user domain) as
string) & "orders.txt"
try
set fid to (open for access gParsePath)
on error
display dialog "Couldn't open " & gParsePath & " for input."
return
end try
repeat
try
set gDataList to (read fid before (ASCII character of 30) using
delimiter (ASCII character of 28))
on error myErrMsg number myErrNo
close access fid
display dialog "EOF"
exit repeat
end try
end repeat
-- end script
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.