Abstract sortobj object for Amiga E
- Size
- 11K (11,564 bytes)
- Added
- 2026-11-20 02:43
- Downloads
- 3
- Long Description
- Long: SortObj for Amiga E This set of objects was created by Trey Van Riper of the Cheese Olfactory Workshop for use with Amiga E. Wear it in good health. This archive has SortObj, String, Integer, and Address. PURPOSE ------- To supply the Amiga E community with an extensible OT class that might help provide for some extreme functionality in the future through reuse (for example, I will very likely create a sorted list class based on this object class) I took the trouble to create SortObj. The basic idea behind 'SortObj' is to have a single object from which other objects can be derived that might allow for sorting in a list or somesuch. I have not yet made such a list, but these objects will still be useful to OT developers working in Amiga E. NOTE: As this is an abstract class, it's extremely low-level. Initially, this object looks on the face of it to be darned useless, but as people start deriving more objects from this one, its flexibility will become more obvious. I am hoping this will help encourage people to release OT objects to help extend Amiga E's usefulness. HOW TO USE ---------- Well.. I suppose I'd best give the SortObj ShowModule output first: ShowModule v1.9 (c) 1992 $#%! now showing: "sortobj.m" NOTE: don't use this output in your code, use the module instead. /* this module contains 620 bytes of code! */ (---) OBJECT sortobj new(a) opts(a) init() lt(a) gt(a) et(a) le(a) ge(a) ne(a) cmp(a) set(a) write() get() id() end() (---) ENDOBJECT /* SIZEOF=4 */ -- new(a) This method is intended to be an intializer. You can pass options to it; I would recommend one passes an Amiga E list rather than a simple value; this will help keep your code extensible. Basically, one shouldn't have to worry about creating their own new() methods as this one calls 'init()' and 'opts()'. -- opts(a) This method allows you to pass special options to the object, in case your object requires several things to be set at various values (examine the Address object). -- init() This method is intended to help you initialize the object, in case it needs it. Maybe you need to NEW some pointers or something. -- cmp(a) This method is VERY important... to get the most out of sortobj, you will want to define this. Basically, this should perform a comparison between something within your object, and something within object 'a' (which should be the same as your own object). Not that the above makes a lot of sense. Generally, 'a' is supposed to be an instance of the object you're creating. 'cmp()' is supposed to compare something within that instance with something inside your 'self' instance. It should return '1' if the 'self' value is greater than the 'a' value, '0' if the two are equal, and '-1' if 'self' is less than the 'a' value. Then, a whole bunch of other functions will become enabled for your procedure... lt()/gt()/le()/ge()/ne()/et() will all instantly start working for you. I recommend you try to make this function work as quickly as possible, as in some cases it might be called twice (eg ge() and le()). -- lt(a) This tests to see if self is less than a. -- gt(a) This tests to see if self is greater than a. -- et(a) This tests to see if self is equal to a. -- le(a) This tests to see if self is less than or equal to a. -- ge(a) This tests to see if self is greater than or equal to a. -- ne(a) This tests to see if self is not equal to a. -- write() This method should return a string to be written by someone else. Perhaps, in the far future, this class could be extended by creating an output object that could be used by sortobj or something.. in the meantime, you can try using this. Basically, make sure this method returns something you could Write