RE: a script object (class) as a member of another script
RE: a script object (class) as a member of another script
- Subject: RE: a script object (class) as a member of another script
- From: "Rua Haszard Morris" <email@hidden>
- Date: Tue, 30 Sep 2003 08:26:42 +1000
Hi all,
Thanks for the responses (summarised below). They have all clarified my
understanding of 'script object'...
but -
What I want to find out is how to use an instance of a script object as a
property of another script object.
i.e. does
script bob
property aCounter : load script "disk:folder:folder:counter.lib"
...
end
work just as well as:
script bob --???
set aCounter to load script "disk:folder:folder:counter.lib"
end
I guess I am confused about the differences between properties and ordinary
variables - what's the difference? What's the significance of the :
operator versus 'set'?
Thanks again,
Rua HM.
>
Message: 3
>
Just write a regular script with properties and methods, then load that
>
as a script object from file. So your counter example would be one
>
object:
>
used as follows:
>
set aCounter to load script "disk:folder:folder:counter.lib"
>
>
Message: 4
>
set counterLib to load script alias ((path to desktop as Unicode text) &
>
"counter.lib")
>
set CounterUser to counterLib's Counter
>
set counterLib to load script alias ((path to desktop as Unicode text) &
>
"counter.lib")
>
set counterLib to load script alias ((path to desktop as Unicode text) &
>
"counter.lib")
>
>
Reply-To: <email@hidden>
>
From: "Rua Haszard Morris" <email@hidden>
>
To: <email@hidden>
>
Subject: a script object (class) as a member of another script object
>
Date: Mon, 29 Sep 2003 15:41:40 +1000
>
>
Hi,
>
>
I'm new to applescript, and am coming to terms with its concept of
>
'class'/'object' - 'script object', right?
>
>
The question I have is how do I define a class in one file (so I
>
can have a
>
lib which is my class/script object, let's say a counter object),
>
and use it
>
in another as a property? To be clear i want to use an instance
>
of a script
>
object (class) as a property (member) of another class.
>
>
e.g.
>
file counter.lib:
>
script Counter
>
property Max : 5
>
property Current : 1;
>
property NumWrapArounds : 0;
>
>
on Count
>
set my Max to my Max + 1
>
...
>
end
>
>
...
>
end
>
>
file counteruser:
>
-- import the counter.lib file somehow? maybe set counterlib to
>
load script
>
file "counter.lib"
>
script CounterUser
>
property mecounterobj : Counter --i.e. an instance of the
>
counter above
>
>
...
>
end
>
>
Is there a way to do this?
>
>
If so, assuming that there are multiple ways to do it (as there
>
are a couple
>
to define a class I beleive), what is the 'normal'/'correct' method?
>
>
Any help would be greatly appreciated...
>
>
Thanks,
>
Rua HM.
>
>
Rua Haszard Morris
>
Software Engineer & Research Assistant
>
MARCS Auditory Laboratories
>
http://www.uws.edu.au/marcs
_______________________________________________
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.