Re: Script Object Order in Script
Re: Script Object Order in Script
- Subject: Re: Script Object Order in Script
- From: Helmut Fuchs <email@hidden>
- Date: Tue, 24 Jul 2001 22:05:22 +0200
At 14:44 Uhr -0400 24.07.2001, Marc K. Myers wrote:
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.
That is, what I too was always thinking, but the following snippet
demonstrates, that this is not always true:
script aaa
property whatever : "aaa"
end script
copy whatever of aaa to testAAA
copy whatever of zzz to testZZZ
script zzz
property whatever : "zzz"
end script
display dialog testAAA & " " & testZZZ
The copy of testZZZ should fail, shouldn't it?
My explanation for this is that the Compiler generates an initial
copy for a script object, if it is on top level and not depending on
runtime values.
Simply bracket "script zzz...end script" with an "if true then...end
if" and it will start behaving as you described above.
As a general rule one shouldn't forward reference script objects or
properties at all. Even if it works, it's likely to break when you
change your code.
This kind of esoteric behaviour on behalf of AppleScript is VERY
annoying, as I tend to often run into it - and never is anything
documented anywhere... or did I miss something?
--
Helmut
** still missing Newton Inc., Newt itself and NewtonScript very much **