Re: script object again
Re: script object again
- Subject: Re: script object again
- From: has <email@hidden>
- Date: Thu, 25 Apr 2002 23:50:46 +0100
nicolas descombes wrote:
>
with this script :
[...]
>
I note that the script object "script exemple" inherits property
>
"maVariable" and subroutine "dialogue". Thus, the script is the parent
>
script object by default of a script object. I'm wrong or right ?
Wrong.:) But an easy confusion.
This isn't inheritance; it's a matter of scope (see ASLG p311-323).
To inherit properties and methods from another script object you use the
'parent' property. Try the following:
======================================================================
on run
tell exemple to addition(2)
maVariable of exemple
end run
script papa
property maVariable : 0
--
on dialogue(txt)
display dialog txt
end dialogue
end script
script exemple
property parent : papa
--
on addition(n)
set maVariable to (my maVariable) + n
dialogue("Valeur de 3maVariable2 : " & maVariable)
end addition
end script
======================================================================
Here the 'exemple' object inherits from the 'papa' object; 'papa' is the
parent of 'exemple'.
Also note the use of the 'my' keyword in the line:
set maVariable to (my maVariable) + n
which is needed to refer to a property in another script object. (You don't
need the 'my' keyword to refer to a property in the same script object.)
This is [also] a scoping issue, so it's a good idea to learn all this scope
stuff before getting into OOP, just so you know what's going on.
HTH
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.