Re: How to coerce a real to an integer in X?
Re: How to coerce a real to an integer in X?
- Subject: Re: How to coerce a real to an integer in X?
- From: "Bob.Kalbaugh" <email@hidden>
- Date: Fri, 01 Feb 2002 12:46:24 -0500
on 1/31/02 10:28 PM, Shane Stanley at email@hidden wrote:
>
On 1/2/02 2:18 PM +1000, Bob.Kalbaugh, email@hidden, wrote:
>
>
> FWIW - OMM - 9.0/1.4:
>
>
>
> integer (3.5)
>
> --> 4
>
>
I still suspect a third-party do-dad. From ASLG (the old print one):
>
>
"AppleScript supports coercion of a Real value to an Integer value only if
>
the Real value has no fractional part."
Well, if you've read Michelle's response to Jon's message you'll note that
she has removed *all* of her scripting additions and it still worked.
Clearly it is something else. Some other do-dad. Possibly an invisible FBA?
I doubt it. That might not even make sense. For the record, all of my tests
were performed from within script editor.
I don't have a printed copy or a printout of the ASLG. And I'm too lazy to
view it on screen. Certainly, I'll take your word for it. I do have Danny
Goodman's book and essentially it says the same thing about coercion of a
Real to Integer. It's mentioned in chapter 11 of my version of the book,
under the topic:
Coercing Values - the As Operator
More specifically:
"...not every value class can be coerced to any other value class. Some
values simply don't have the right stuff to become another class."
and from His coercion table guide:
From To Example Tips
--------------------------------------------------------
Real Integer 5.0 -> 5 Only if real has no fractional parts
String Integer "5" -> 5 Only if string represents a Real
----------------------------------------------------------
Well I also get this:
integer ("5.3")
--> 5
and similar to the example in my previous post
("5.3") as integer (fails)
--> "Cant make "5.3" into a integer
In the first example we are not using an operator. (Are we?) But in the
second example we are. And it fails as it should according to the
documentation. But to me it seems like the same thing. So AppleScript is
doing something different with the first one. I just don't know what it is.
Obviously its coercion. But who? What? The book also states that AppleScript
trys to handle coercion for us changing the right operand based on what the
left one is.
All-in-all, Your guess is probably way better than mine, but I think it is
just AS helping us out in the first example. We're NOT using the "as"
operator. And it's undocumented anywhere.
--
Bob.Kalbaugh