MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nigel Garvey <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sun, 18 May 2003 14:29:04 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
Walter Ian Kaye wrote on Sat, 17 May 2003 17:01:22 -0700:

>At 03:20p +0100 05/17/2003, Nigel Garvey didst inscribe upon an
>electronic papyrus:
>
>>Walter Ian Kaye wrote on Fri, 16 May 2003 14:12:27 -0700:
>>
>>>Is unexpected behavior of an unsupported coercion considered a bug?
>>>I guess nobody's tried '1.5 as integer' lately.
>>
>>It's the double integer itself that's not supported in AppleScript,
>>otherwise a coercion to it would have to be supported to make it
>>usable. The only number types mentioned in ASLG are integer and
>>real. Anything else is for the language's internal use or for future
>>expansion, not something that scripters are supposed to see or use.
>
>Oh I don't know about that. It could also be argued that any type
>which decompiles to a corresponding English term is indeed something
>that scripters may use. Of course any term is subject to change, as
>we saw in the transition from System 7 to 8 where the code for file
>types got "(obsolete)" tacked on; such changes are not limited to
>"internal use" codes.

While reviewing this thread last night, I checked up on Paul's comment
about 'read' taking 'double integer' file-position parameters, and found
that this is indeed the case. According to the more recent Standard
Additions dictionaries, most of the File Read/Write commands either
accept or return double integers, while 'open for access' returns a
'small integer'. In the Standard Additions 1.3.7 dictionary (OS 8.6), the
position parameters are plain 'integer', but 'open for access' still
returns a 'small integer'.

In Script Editor, numbers that are coerced to 'small integer' are
reported as being simply 'integer'. Numbers that are too big to be so
coerced cause errors. Fractional numbers that are so coerced are - as
with coercions to double integer - rounded off in the IEEE fashion.

Like their coerced counterparts, the double and small integers returned
by the File Read/Write commands are reported as being of class 'real' and
class 'integer' respectively.

Since it's not necessary to specify the number type when using a File
Read/Write parameter, it would seem that the coercion to double takes
place automatically. This is born out by the following little perversity:

  set fred to (path to desktop as string) & "Impact Percussion.html"
  set bert to read file fred for 100.5
  count bert
  --> 100

  set bert to read file fred for 100.5001
  count bert
  --> 101

I get exactly the same results when running the script in OS 8.6, so
those plain 'integers' must really be doubles too.

NG

ATOM RSS1 RSS2