Re: Fun with coercing to string
Re: Fun with coercing to string
- Subject: Re: Fun with coercing to string
- From: email@hidden
- Date: Tue, 20 Feb 2001 23:32:00 -0500
On Tue, 20 Feb 2001 16:08:21 -0500, "Stephen Swift (aka Burnum)"
<email@hidden> asked,
>
Mac OS 8.1
>
AppleScript 1.1.2
Good start!
>
WHAT WORKS:
>
month of (current date) --> February
>
>
set ThisMonth to month of (current date)
>
display dialog ThisMonth
>
--displays a dialog box with the text 'feb'
>
>
set ThisDate to day of (current date)
>
display dialog "It is the " & ThisDate & "th of February."
>
--displays a dialog box with the text 'It is the 20th of February."
>
WHAT DOESN'T WORK:
>
set ThisMonth to month of (current date)
>
display dialog "We are in the month of " & ThisMonth
>
--Can't make February into a string
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'm surprised that Display Dialog can handle the constant and get a string out
of it. But regardless, to evaluate the expression, "The month of " & ThisMonth,
you need to coerce the month into a string. And for that, you need OS 8.6 at
least.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden