Re: Handler joy
Re: Handler joy
- Subject: Re: Handler joy
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 28 Feb 2001 10:31:53 -0800
On 2/28/01 10:05 AM, "Nigel Garvey" <email@hidden> wrote:
>
JollyRoger wrote on Wed, 28 Feb 2001 10:37:25 -0600:
>
>
> on 2/28/2001 4:35 AM, Cal at email@hidden wrote:
>
>
>
>> Jolly Roger <email@hidden> replied:
>
>>
>
>>> Not sure. This works fine for me:
>
>>>
>
>>> -- begin script
>
>>> property ProcessedFolder : "Mac HD:"
>
>>>
>
>>> return my CheckProcessed(ProcessedFolder)
>
>>>
>
>>> -- get the number of items of ProcessedFolder
>
>>>
>
>>> on CheckProcessed(pFolder)
>
>>> get the number of items of pFolder
>
>>> end CheckProcessed
>
>>> -- end script
>
>>
>
>> Not really, Roger. (Actually, it depends on your definition of
>
>> "works fine". If you mean, "it runs and gives me some sort of
>
>> answer" then yes. But if you mean "it runs and gives the number of
>
>> items in a folder, then no.)
>
>
>
> Cal,
>
>
>
> It gives me the number of items in the folder. I ran it from within Smile -
>
> think that makes a difference? Hmm, no, I just ran it from within Script
>
> Editor and it worked there too. So why is it working for me, but not for
>
> you guys?
>
>
The obvious answer is "Jon's Coercions", but the interesting question is:
>
How does the handler get the number of items in the folder without the
>
help of the Finder? The script works for me in this form:
>
>
property ProcessedFolder : "4400 HD:"
>
>
tell application "Finder"
>
return my CheckProcessed(alias ProcessedFolder)
>
end tell
>
>
-- get the number of items of ProcessedFolder
>
>
on CheckProcessed(pFolder)
>
get the number of items of pFolder
>
end CheckProcessed
>
>
For it to work, I have to use 'alias' in the call parameter (not 'file')
>
and the call has to be in a Finder 'tell' block. It looks as though
>
pFolder is being recognised as belonging to the Finder (?) and that the
>
Finder is therefore invoke to get the 'number of items' in it (??). I've
>
seen similar things before with Finder objects, but with an alias
>
specification?
>
What I find odd about your description (I haven't got rid of my osaxen to
test this myself) is that the handler call has to be in a tell "Finder"
block. Isn't the use of 'my' in a handler call specifically meant to take
the call outside any reference to an application block, but rather to the
top script level? And 'number', the thing returned by the handler, doesn't
need an application to interpret it. There's an implication here that
'number of items of pFolder'
must get returned unevaluated, not as a number but rather as
number of (various things with Finder class names)
which only get evaluated when inside a Finder tell block. This does seem
very strange.
--
Paul Berkowitz