Re: vdate
Re: vdate
- Subject: Re: vdate
- From: Nigel Garvey <email@hidden>
- Date: Tue, 6 Nov 2001 14:33:59 +0000
Christopher Nebel wrote on Mon, 5 Nov 2001 17:21:55 -0800:
>
On Monday, November 5, 2001, at 08:56 AM, Robert Poland wrote:
>
>
> The following crashes on my wifes 6100, OS 8.1. I tried Applescript
>
> 1.1.3.
>
>
>
> set DateString to "" & (vDate)'s month & " " & (vDate)'s day & ", " &
>
> (vDate)'s year -- month, day, year
>
>
>
> Error says it cannot make month "November into a string".
>
>
Yep. The month of an AppleScript date object isn't really a string,
>
it's an enumeration, and AppleScript didn't support coercing
>
enumerations to strings prior to 1.4. Since you're using 1.1.3, you'll
>
have to do it the hard way, like this:
>
>
if (vDate)'s month is January then
>
set m to "January"
>
else if (vDate)'s month is February then
>
set m to "February"
>
(etc.)
Or of course there's the old 'error message' trick:
try
set m to vDate's month as string
on error msg
set m to word 3 of msg
end try
This assumes that vDate is a valid date. There's no error with later
AppleScript versions, but with earlier versions, the month name string is
taken from the error message. The result is styled text, but I don't
think this would be a problem.
NG