Re: Where to report Script Editor bug?
Re: Where to report Script Editor bug?
- Subject: Re: Where to report Script Editor bug?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 20 Feb 2004 10:42:06 -0800
On 2/20/04 10:10 AM, "Richard Rvnnbdck" <email@hidden> wrote:
>
This:
>
>
set myConvertedTemp to (32 as degrees Fahrenheit) as degrees Celsius
>
get myConvertedTemp as string
>
>
will result in:
>
>
" 0e+0"
>
>
but when run from the Script Editor, but when run from Script Debugger, the
>
script menu, or saved as an application, it will return 0
>
>
Easy enough to work around, but should probably be reported anyway, so where
>
do I do that?
1. I get exactly the same result (" 0e+0") in Script Debugger.
2. It's not a bug. Who said 'degrees Celsius' was supposed to coerce
directly to string?
If you do just
set myConvertedTemp to (32 as degrees Fahrenheit) as degrees Celsius
--> 0.0 degrees Celsius
You can coerce that to a real or to an integer easily:
get myConvertedTemp as real
--> 0.0
get myConvertedTemp as integer
--> 0
If you're not in Panther, you should stick with 'as real' or else do a div 1
or round operation on the real to get an integer if that's what you want, in
case the real isn't a whole number. (Only in Panther can you coerce reals to
integers if they're not whole numbers ending in .0).
And then coerce the real or integer to string:
get myConvertedTemp as real as string
--> "0.0"
get myConvertedTemp as integer as string
--> "0"
If not in Panther, I'd do this:
set myConvertedTemp to (round ((33 as degrees Fahrenheit) as degrees
Celsius as real)) as string
--> "1"
In Panther, this will also work:
set myConvertedTemp to ((33 as degrees Fahrenheit) as degrees Celsius as
integer) as string
--> "1"
There are also ways to get it to 1 or 2 decimal places, as you wish. (You
probably don't want this:
set myConvertedTemp to ((33 as degrees Fahrenheit) as degrees Celsius as
real) as string
--> "0.555555555556"
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.