Re: global variable not being recognized by script object
Re: global variable not being recognized by script object
- Subject: Re: global variable not being recognized by script object
- From: Richard 23 <email@hidden>
- Date: Wed, 28 Feb 2001 20:03:30 -0800
>
> "my" also tells AppleScript to look outside of the current scope.
>
> If a global is declared at the top level a single my reference
>
> is sufficient (as long as the first occurence in the handler uses
>
> my.
>
>
Aha! You have just provided invaluable service to users of Smile, Richard.
>
When calling entire handlers from a debugging Text window in Smile, you need
>
to have put "my" before any property or global variable from the main script
>
before "entering" the handler to use it in debugging. This is quite a
>
bother. It is because it behaves exactly as Scott described: the variables
>
in the "saved" (declared, what-have-you) handler don't know about any global
>
variables or properties when it is "entered". But if you only need to put
>
"my" once per variable, that's very convenient. I shall check it out.
Well yes, but I dunno how reliable that little trick is. I tend to not
use globals that often and when I do I specify any globals used by the
handler in its first line.
Another method I'll use to avoid using "my" and "tell" concerns script
libraries. If I load in a script object and specify its parent as the
calling script I can get around having to direct calls at the child by
telling the child to call a handler in the parent. Any calls to the
child's handlers within the parent's handler can refer to the child's
handlers without an explicit reference. This is not true of script
properties but it is half of the battle!
R23