Re: vdate
Re: vdate
- Subject: Re: vdate
- From: has <email@hidden>
- Date: Tue, 6 Nov 2001 04:33:13 +0000
Christopher Nebel wrote:
>
>
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.)
>
>
Alternatively, you could ask for "date string of vDate" and then trim
>
off the day of the week, or you could get one of several more flexible
>
date formatting additions.
Another way would be to use the "R23" approach: trap the error, and set m
to text ?? thru -?? of the error string. (You'll have to work out the exact
numbers for yourself.)
try
--do the thing that causes a known error, with a known error message
on error errorMsg
set m to text ?? thru -?? of errorMsg
end
If you're being thorough, you would double-check the error number just to
make absolutely sure it's not some other error (and throw an permanent
error if it is).
has
p.s. Ta to Chris for highlighting the pre-1.4 problem - I wasn't aware of
it myself... must put that on my things-to-do/workaround list.
p.p.s. Robert: don't suppose you could mail me a copy of the exact error
string you get so I can add pre-1.4 support to the dateFormat library I'm
doing.