Re: Passing *possible* variables to a handler
Re: Passing *possible* variables to a handler
- Subject: Re: Passing *possible* variables to a handler
- From: Nigel Garvey <email@hidden>
- Date: Thu, 18 Jul 2002 12:35:23 +0100
email@hidden wrote on Wed, 17 Jul 2002 20:40:14 -0400:
>
On Wed, 17 Jul 2002 13:53:46 +0100,
>
has <email@hidden> wrote,
>
>
> Nigel Garvey wrote:
>
[...]
>
> > on handler1(val1, val2)
>
> > script obj
>
> > property prop1 : val1
>
> > property prop2 : val2
>
> >
>
> > on privateHandler(val3) -- dummy handler :-)
>
> > [...]
>
> > end privateHandler
>
> > end script
>
> > end handler1
>
>
> Ey lad, looks like you've almost incidentally discovered constructor
>
> functions (except that your example above doesn't actually return the
>
> script object created).
>
>
Actually, it almost does. Oddly, "script obj...end script" doesn't set
>
'result', but an anonymous "script...end script" does.
Have you guys discovered a version-specific bug? Script objects *always*
return run-time results on my machines - unless they're at the very top
level of a script. Then I get the same effect that Scott describes. (I'm
using AS 1.6 and AS 1.3.7.)
Linking this with what has wrote yesterday:
>
>If you include a script object definition at the top level of a
>
>script-that is, as
>
>part of the script's Run handler-AppleScript initializes the script object
>
>each
>
>time the script's Run handler is executed. For more information, see "Run
>
>Handlers" (page 303).
>
>
This is potentially misleading. If you declare the script object within an
>
_explicit_ run handler, it is indeed true. If you truly declare it at the
>
top level, ie outside the run handler (which is also the case if no
>
explicit run handler is declared), then the script object is initialised at
>
*compile-time*.
... I find that, at the very top level of a script, *named* script
objects are intialised at compile time. Anonymous ones aren't.
script obj
property fred:display dialog "Hello"
end
--> Dialog displays at compile time, not at run time
script
property fred:display dialog "Hello"
end
--> Dialog displays at run time, not at compile time. result =
<<script>>
Inside a handler - 'run' or otherwise - the dialog only displays at run
time and the result is the appropriate version of <<script>>.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.