Re: Date weirdness from Finder
Re: Date weirdness from Finder
- Subject: Re: Date weirdness from Finder
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 13 Oct 2001 19:33:21 -0700
On 10/13/01 7:20 PM, "Irwin Poche" <email@hidden> wrote:
>
Can anyone tell me why these two lines of code, taken straight out of the
>
AppleScript Guidebook, works only when they're -NOT- enclosed in a "Tell
>
Finder" block ?
>
>
set the numeric_date to "01/20/2002"
>
set the target_date to date the numeric_date
>
>
When in a Finder tell block, the second line gets the error "Finder got an
>
error: Can't get Date 01/20/2002."
>
>
>
If the script is changed to this, then it works correctly.
>
>
tell application "Finder"
>
set the numeric_date to "01/20/2002"
>
tell me to set the target_date to date the numeric_date
>
end tell
It's not just the Finder - that happens in any tell tell block when you try
to get the date. Have you noticed that when you _compile_ (check syntax),
that your script changes
date "01/20/2002"
(outside a tell block) to
date "Sunday, January 20, 2002 12:00:00 AM" -- or equivalent in local
format and language on your computer
Even though your script above uses a variable, AppleScript has to compile it
the same way behind the scenes and check to see if it's a valid date. The
app being "told" can't do this, so you need the workaround of 'tell me to
set date' (or 'tell AppleScript to set date') as you found out, if you're in
a tell block.
--
Paul Berkowitz