Re: Read file bug?
Re: Read file bug?
- Subject: Re: Read file bug?
- From: Timothy Bates <email@hidden>
- Date: Mon, 21 Apr 2003 22:15:18 +1000
>
> If I open a file and read until the end of a line, I expect to eventually
>
> error as we hit the eof.
>
Here it throws a "End of file error." (AS 1.9.1, OS 10.2.5)
Turns out it is a bug to do with unix line endings. I have filed a radar
report with a text file that fails to generate the EOF error that I was
wanting.
>
> This code, however, loops forever. Bug or misunderstanding. How does one
>
> know that the last line has been read?
>
> (the "posit" bit won't compile if you are not using smile. I use it as a
>
> textual progress indicator)
>
>
>
> property pPathToDataFile : "path:to:a:text:file"
>
> set f to open for access file pPathToDataFile
>
> set targetString to "not in this file"
>
> set n to 1
>
> set nextN to 1
>
> repeat
>
> set a to read f until ASCII character 10
>
> if n > nextN then
>
> postit n & "" & a as string
>
> set nextN to n + 50
>
> end if
>
> set n to n + 1
>
> end repeat
>
>
>
> close access file pPathToDataFile
_______________________________________________
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.