• 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: EOF madness!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOF madness!


  • Subject: Re: EOF madness!
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 10 Apr 2001 14:44:59 -0700

On Tuesday, April 10, 2001, at 07:28 AM, bRaD Weston wrote:

I am trying to read a text file until eof and Applescript has lost
its mind. It is only reading the first 25 - 29 characters of the file
and thinks it's done. Other machines seem to work fine with this ever
so simple script. Any ideas? This is the latest trial, but there have
been several before this:

set the tempFile to open for access file sourceFile without write permission
set rawData to read tempFile from 1 until eof

Uh oh -- it looks like the AppleEvent Manager is being overly helpful again. I'll bet the result you get has an "e" as the last character, right? What you actually want is "read f from 1 *to* eof". "Until" means "read up to and including the character I specify," and it's misinterpreting the enumeration eof (which has a code of "eof ") as the character "e". I'm probably going to have to add a special case for this.

Incidentally, if you're not going to read other things from the file, you don't need to open the file first -- read will open it for you and close it again afterwards. If you want the entire contents, you don't need to specify "from 1 to eof", because that's what read does by default. (Actually, it reads from the current position to the end of the file, but if you've just opened it, then the current position is at the beginning.) So your script could simply be:

set rawData to read file sourceFile


--Chris Nebel
AppleScript Engineering


References: 
 >EOF madness! (From: bRaD Weston <email@hidden>)

  • Prev by Date: Re: applescript-users digest
  • Next by Date: path to constants
  • Previous by thread: Re: EOF madness!
  • Next by thread: Re: EOF madness!
  • Index(es):
    • Date
    • Thread