• 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: Reading Lines of Text from File Until EOF...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading Lines of Text from File Until EOF...


  • Subject: Re: Reading Lines of Text from File Until EOF...
  • From: "Marc K. Myers" <email@hidden>
  • Date: Tue, 30 Jan 2001 13:25:02 -0500
  • Organization: [very little]

Robert B. Parker wrote:
> Date: Tue, 30 Jan 2001 07:39:19 -0700
> Subject: Reading Lines of Text from File Until EOF...
> From: "Robert B. Parker" <email@hidden>
> To: applescript users <email@hidden>
>
> I've searched the archives, but haven't found exactly what I'm looking for,
> so I thought I'd ask the group...
>
> I have a text file that I want to read data out of. Each line of the data
> file has the exact same number of characters in it and I've already got my
> script to the point where it can parse out the info it needs from each line
> of text.
>
> My script is also acquiring each line of text from the file - sort of. The
> problem I'm having is having the script gracefully close the file and exit
> when it has hit the End of File (EOF).
>
> If anyone has some sample code they could send my way (email@hidden)
> I'd GREATLY appreciate it.

You need to wrap your read statement in a "try....on error....end try"
structure and trap for the EOF error.

repeat
try
read someFile before return
[whatever you do with the line of text]
on error errMsg number errNbr
if errNbr = -39 then -- EOF error
[whatever you do at EOF]
exit repeat
else
error errMsg number errNbr -- a "real" error
end if
end error
end repeat

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[1/30/01 1:23:33 PM]


  • Prev by Date: Re: Folder action
  • Next by Date: Re: linimg to moving target with folder actions
  • Previous by thread: Re: Reading Lines of Text from File Until EOF...
  • Next by thread: newbie: how do you click 'ok' in as
  • Index(es):
    • Date
    • Thread