Re: Multi-Versions
Re: Multi-Versions
- Subject: Re: Multi-Versions
- From: Christopher Nebel <email@hidden>
- Date: Fri, 14 Dec 2001 12:07:48 -0800
On Friday, December 14, 2001, at 04:19 AM, Jack Rarick wrote:
Am I correct to assume that each version of Applescript has with it a
different set of Standard Additions? And if so, and specifically in the
case of:
read from file anyFile until eof (pre 1.6)
and
read from file anyfile from 0 to (get eof of file anyfile) (1.6)
is it appropriate to test for the version number and then use the write
coding? or ... am I missing something here?
You can do this, though as John Baxter points out, people are known to
mix and match versions of AppleScript and Standard Additions, so asking
for AppleScript's version isn't a reliable indicator of what you've
got. You could use the Finder to get the version of Standard Additions
itself, and that would tell you what you need.
In this particular case, however, both your commands are bogus. First
and most seriously, "read" doesn't take the file as the "from"
parameter, it takes it as the direct parameter (i.e., no preposition).
Second, "until eof" doesn't do what you think it does -- it will
actually read until the first "e" in the file. (This is partly a bug
and partly by design. As the dictionary states, "until" is only
supposed to be used with a character to read until -- to read to a
specific offset, including eof, use the "to" parameter.)
Third, you don't need the explicit "from" and "to" parameters at all.
"read" always reads to the end of the file unless you tell it otherwise,
and it always starts at zero unless you've moved the mark by reading or
writing part of the file.
This command would be more correctly written
read file anyFile
...and that would work pre- or post-1.6.
--Chris Nebel
AppleScript Engineering