Re: Newbie Script Error - Help?
Re: Newbie Script Error - Help?
- Subject: Re: Newbie Script Error - Help?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 18 Apr 2003 10:33:31 -0700
In a tell block, terms that aren't defined variables are assumed to be
application keywords. In a handler, variables that aren't declared as global
are assumed to be local.
Handler names are just like variables at the "top-level" (implicit or
explicit run handler) of a script, which are actually all globals. (Regular
top-level variables which are not explicitly declared as global can't be
referenced inside handlers - but they can be declare global there if you
wish - showing that the script actually knows about them, even inside
handlers. They have persistence, for example, just like declared globals.)
Only script properties can be referenced from within a handler without 'my'
(and 'my won't hurt there either.)
'my' is the way to reference a global variable, or a handler, or a script
object, from within a handler of tell block. 'my' means that it belongs to
the script itself, not to a containing application tell block, and that it
is not local to the handler you're in. Another handler's name simply cannot
be seen by the handler you're calling from, since a handler can only see
what's local to it. But as soon as you use 'my', you open up the script's
own set of top-level set of globals, handlers and script objects.
--
Paul Berkowitz
>
From: "Wallace, William" <email@hidden>
>
Date: Fri, 18 Apr 2003 12:03:25 -0500
>
To: "'email@hidden'" <email@hidden>
>
Subject: RE: Newbie Script Error - Help?
>
>
Could someone please clarify or summarize the reasons behind the use of "my"
>
in the call to a handler (or point me to a very specific and definitive
>
resource on this subject)? I've also encountered this issue, and I'd just
>
like to have a more concrete understanding of the when's and why's of using
>
"my" in calling a handler.
>
>
whw
>
>
> On 4/18/03 7:05 AM, "Robert Damm" <email@hidden> wrote:
>
>
>
>> I am starting to write a synchronisation applescript for address book to
>
>> entourage. This is the beginning of it...and it fails with
>
>>
>
>> "Address book got error: Can't continue find_contact"
>
>>
>
>> Help?
>
>
>
> You usually get that error when you call a handler from within a tell block
>
> or from within another handler and forget to include 'my'. You need to
>
> call:
>
>
>
> my find_contact(first_name, last_name)
>
>
>
> Similarly within that handler I see you call another one
>
>
>
> create_contact(first_name, last_name)
>
>
>
> You need to call
>
>
>
> my create_contact(first_name, last_name)
>
>
>
> or you'll get the same error there.
>
_______________________________________________
>
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.
_______________________________________________
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.