Re: inheritance
Re: inheritance
- Subject: Re: inheritance
- From: Axel Luttgens <email@hidden>
- Date: Thu, 15 Jan 2004 11:05:20 +0100
Wallace, William wrote:
Shouldn't a loaded script object inherit everything from the main script into which it was loaded. In other words shouldn't handlers within the loaded script object be able to see (and change the value of) variables declared as global in the main script? make use of handlers defined in the body of the main script? Or do I have to explicitly declare the main script as the parent of the loaded script object in order to inherit these things? If so, how does one refer to the top level script?
B!ll
Not sure if this may be of some help...
Inheritance
-----------
Let's save following code into a file named "test.scpt"
on doThat()
doThis()
end doThat
Now, in the Script Editor, let's type and run:
on doThis()
display dialog "hey!"
end doThis
set test to load script alias "
Data:Users:luttgens:Desktop:test.scpt"
tell test to doThat()
--> <<script>> does not understand doThis.
Now, instead of running the second snippet in Script Editor, let's save
it as an applet and double-clic on its icon.
The dialog "hey!" now appears...
From the ASLG: "The current application is either the default target
application or whatever application is currently set as a scripts
parent property. The default parent property for any script that doesnt
explicitly declare one is the default target application usually, the
application that is running the script, such as the Script Editor."
Above script "test" didn't define a parent; its parent thus defaults to
the default target application.
In the first "experiment", this was the Script Editor, which doesn't
know about doThis().
In the second one, this was the applet itself.
Did you perform your trials from the Script Editor?
Globals
-------
Inheritance goes about handlers and properties.
Globals are not inherited, they belong to a global name space, which is
accessible either because of some scoping rules, or because you made
them appear in a 'global var1, var2...' statement.
Did you use the 'global' statement?
HTH,
Axel
_______________________________________________
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.
References: | |
| >inheritance (From: "Wallace, William" <email@hidden>) |