Re: Script Object Order in Script
Re: Script Object Order in Script
- Subject: Re: Script Object Order in Script
- From: "Marc K. Myers" <email@hidden>
- Date: Tue, 24 Jul 2001 14:44:09 -0400
- Organization: [very little]
>
Date: Tue, 24 Jul 2001 11:34:32 -0400
>
Subject: Script Object Order in Script
>
From: Arthur J Knapp <email@hidden>
>
To: <email@hidden>
>
>
Is this a bug, or a feature? :
>
>
script aaa
>
property whatever : "aaa"
>
end script
>
>
on CheckScriptProperties()
>
>
whatever of aaa --> "aaa"
>
>
whatever of zzz --> error "The variable zzz is not defined."
>
>
end CheckScriptProperties
>
>
script zzz
>
property whatever : "zzz"
>
end script
>
>
CheckScriptProperties()
>
>
In other words, the handler CheckScriptProperties can't "see"
>
the script object zzz, appearently because it is defined after
>
the handler is. I don't understand why it should behave this way.
>
>
Handlers have no difficulty calling on other handlers that have
>
been defined after them, as in:
>
>
on HandlerAtTop()
>
return "HandlerAtTop"
>
end HandlerAtTop
>
>
on CallHandlers()
>
>
HandlerAtTop() --> "HandlerAtTop"
>
>
HandlerAtBottom() --> "HandlerAtBottom"
>
>
end CallHandlers
>
>
on HandlerAtBottom()
>
return "HandlerAtBottom"
>
end HandlerAtBottom
>
>
CallHandlers()
>
>
It seems to me that after the script has been compiled, all
>
script objects defined at the top-level of the script should
>
be just as "global" as all handler definitions.
The difference is that the script object doesn't come into being until
its code is executed. This initializes the script object. Handlers, by
contrast, come into existence when the script is compiled.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[7/24/01 2:43:49 PM]