• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Read - testing for EOF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read - testing for EOF


  • Subject: Re: Read - testing for EOF
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 20 Jan 2004 10:06:37 +0100

Chap Harrison wrote:

How do you know when you've reached EOF when reading a file sequentially, record by record?? (using Standard Additions read)

Reading when at EOF seems to *usually* throw an error, which can be caught in a try... on error block, but it doesn't seem to be dependable. Sometimes it returns the final record twice before throwing the error; sometimes it returns a null record infinitely.


You are right (well, I think so ;-) ) when thinking that something along those lines should do the job:

repeat
try
set chunk to read R until myDelim
[ process read chunk here ]
on error
[ do some cleanup here if needed ]
exit repeat
end try
end repeat

But yes, while preparing my reply yesterday, I encountered behaviors similar to the ones you are describing.
As it appeared very elusive, I wasn't sure if it was me or AppleScript, so I wanted to investigate a bit further; but I wouldn't leave you alone...

Here is a case I can reproduce:
1. write sequence "aaaLbbbLcccSdddLeeeLfffLS" to
a file (with no ending CR or LF), where L in fact
is ASCII number 163 and S is ASCII number 164.
2. run a script similar to the above, where myDelim
is set to ASCII character 163
Result: an endless loop, with the last pseudo-L read ad infinitum.

Should you have them at hand, could you post minimal sample data/code producing similar effects?



Thanks,
Chap

PS - Am I missing a vital documentation resource? Please let me know - I can't believe I'm having such a hard time finding answers to these simple questions myself. :-(


Some times ago, I posted this link:

http://manuals.info.apple.com/Apple_Support_Area/Manuals/software/0305098AASADDGENG.PDF

Very old, but still a reference the same way the ASLG is.
(as far as the file-related commands are concerned, this was before the "using delimiter" argument and before unicode...)


HTH,
Axel
_______________________________________________
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.

  • Follow-Ups:
    • Re: Read - testing for EOF
      • From: Chap Harrison <email@hidden>
    • Re: Read - testing for EOF
      • From: Axel Luttgens <email@hidden>
References: 
 >Read - testing for EOF (From: Chap Harrison <email@hidden>)

  • Prev by Date: Re: Setting the due date of an existing task in Entourage to 'no due date'
  • Next by Date: Re: Setting the due date of an existing task in Entourage to 'no due date'
  • Previous by thread: Read - testing for EOF
  • Next by thread: Re: Read - testing for EOF
  • Index(es):
    • Date
    • Thread