Re: *Very* strange script / global variable behavior
Re: *Very* strange script / global variable behavior
- Subject: Re: *Very* strange script / global variable behavior
- From: Nigel Garvey <email@hidden>
- Date: Tue, 1 Mar 2005 12:44:07 +0000
has wrote on Mon, 28 Feb 2005 22:38:44 +0000:
>Nigel Garvey wrote:
>
>> >And this script object, being the top-level script
>>>object, is created at compile-time; ergo the script object in Outer
>>>is also created at compile-time.
>>
>>Not according to ASLG, but maybe you have a better source:
>
>The ASLG is mostly incorrect. A named script object declared within
>another script object is initialised when the parent script object is
>initialised, same as property values and handler objects. Only
>unnamed script objects and script objects within declared handlers
>are initialised when the relevant code is executed. Simple
>demonstration showing when initialisation occurs:
Ah, I see. A top-level script object that's named at compile-time would
*have* to be initialised then in order to be assigned to the variable.
And any of its own, named, top-level subscripts would have to follow
suit. Thanks. Good demo.
In Neil's example script, the 'Inner' script object is in a handler and
presumably not initialised. Interestingly, if the 'Outer' script object
is initialised and named at run-time instead, the "State 0" problem
doesn't occur.
script
-- Blah blah blah
end script
set Outer to the result
Also, in the original version, the "State 0" problem can be changed to a
"State 12" problem by setting 'theState' to 12 immediately before setting
'x' to 'Outer', so it's nothing to do with the value of 'theState' when
the script's compiled. It seems there's just something flaky about script
objects that are initialised when they're compiled.
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden