Re: Fun with coercing to string
Re: Fun with coercing to string
- Subject: Re: Fun with coercing to string
- From: Richard 23 <email@hidden>
- Date: Wed, 21 Feb 2001 17:47:44 -0800
>
The month property of a date is a constant, like February. It can't be
>
coerced into a string, "February" in AppleScript 1.1.2.
>
In 1.3.7, they added that coercion. Some things can display these constants,
>
like the Event Log and the result window, but on the inside, this isn't string
>
coercion, its decompiling.
I dunno. I don't think I can run a pre-8.6 version of AppleScript on my
current Mac but I suspect that AppleScript is just a dirty rotten fibber.
I can't demonstrate on February since a constant coercion is present and
so that wouldn't have any meaning. But I can take a value it claims to
not be capable of coercing, say raw data, and get it as styled or plain
text. This is what CoerceToString does. I've been doing the same sort
of thing since well before 1.3.6 at least I think so.
let's make up a raw data value. Since we're limited to hexadecimal and
I don't really get a kick out of passing secret messages back and forth
let me point out that the hex value used in this example does not decode
to some hidden message so don't waste your time.
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d3
-- ---------------------------------------------------------
on run
-- So here's our randomly selected raw data value:
set theData to <<data DEADBEEF>>
display dialog theData
--> Can't make +data DEADBEEF; into a string.
theData as string
--> Can't make +data DEADBEEF; into a string.
CoerceToStringJr(theData)
--> "<<data DEADBEEF>>"
end run
on CoerceToStringJr(theValue)
try
error number -1700 from theValue
on error errTxt number -1700
<<class ktxt>> of (errTxt as record)
result's text 12 thru -14
end try
end CoerceToStringJr
-- ---------------------------------------------------------
Considering how easy this was I'd say that AppleScript is being
a dirty rotten fink of a creepy liar. So now you know. 8)
R23