Re: Read file bug?
Re: Read file bug?
- Subject: Re: Read file bug?
- From: John Delacour <email@hidden>
- Date: Mon, 21 Apr 2003 18:12:41 +0100
- Mac-eudora-version: 6.0a16
At 10:17 pm +1000 21/4/03, Timothy Bates wrote:
>> If I open a file and read until the end of a line, I expect to eventually
error as we hit the eof.
But not if you *never find* an end of line! You were trying to read
a file delimited with carriage returns and not line feeds, so the
script was reading until doomsday on the first iteration.
It is finding line endings (and they are line feeds) just fine. The bug is
that is keeps returning the last line over and over and over until
cancelled, rather than reporting the EOF. Turns out that read file has a
problem with unix line endings in some files, one of which I had created.
I obviously didn't make myself clear when I replied on Thursday, So
far as I can see there is no bug. It may be inconvenient not to know
from one moment to the next in OS 10 how lines are terminated, but
that does not constitute a bug. The script below works as expected.
If you have a short script that demonstrates your "bug" then post it
here and let us see.
set fU to "/tmp/t"
set f to POSIX file fU
set lf to ASCII character 10
try
close access f
end try
open for access f with write permission
set eof f to 0
repeat 10 times
write "x" & lf to f
end repeat
close access f
open for access f
set i to 0
repeat
try
set i to i + 1
read f until lf
on error
exit repeat
end try
end repeat
return "" & i & " lines read"
close access f
JD
_______________________________________________
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.