• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: a script object (class) as a member of another script object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a script object (class) as a member of another script object


  • Subject: Re: a script object (class) as a member of another script object
  • From: tim bates <email@hidden>
  • Date: Mon, 29 Sep 2003 17:13:56 +1000

I'm new to applescript, and am coming to terms with its concept of
'class'/'object' - 'script object', right?

pretty much everything in applescript is an object. A script object is just an object which has methods of its own. Most often these are loaded from a script file, but you can create them inside a script if you want too.

[The question I have is how do I define a class in one file (let's say a counter object), and use it
in another?]

Much easier to not use script objects within the file you are going to load: instead stick to one object per file, then load multiple files to instantiate each of the objects you want.

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:

file counter.lib:
property Max : 5
property Current : 1;
property NumWrapArounds : 0;

on Count()
set my Max to my Max + 1
...
end


used as follows:
set aCounter to load script "disk:folder:folder:counter.lib"

tell a counter
display dialog Max
--> 5
Count()
display dialog Max
-->6
end
_______________________________________________
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: 
 >a script object (class) as a member of another script object (From: "Rua Haszard Morris" <email@hidden>)

  • Prev by Date: Re: Bug in (scripting) Excel.
  • Next by Date: Re: a script object (class) as a member of another script object
  • Previous by thread: a script object (class) as a member of another script object
  • Next by thread: Re: a script object (class) as a member of another script object
  • Index(es):
    • Date
    • Thread