This class provides a mechanism for mapping objects to integers, and vice versa. Its name, "Oi," is short for "Object integer."
Synergy/DE, being a type-safe language, is not friendly to the idea of passing an object as a parameter where a primitive type is expected. Nor can you pass a record or group that contains an object. Thus, a disconnect can easily occur when you wish to use an object in a routine that must be called back from a mechanism where only primitives can be passed.
The obvious solution to this problem is to keep an array of the objects you need to reference, and pass their indices instead of their references. Care must be taken to keep the indices from changing as objects are added or removed. That's what this class encapsulates.
Naturally, adding an object to this mechanism creates a reference, so you must be careful to "drop" an object from Oi when you no longer need it. Oi will reuse that index of its internal array.
Words in italics indicate an instance of a class. The word corresponds to the class name, except where more than one instance is represented in the same statement. In that case a number (2, 3, etc.) is appended to the class name.
Words in normal typeface are to be taken literally (required punctuation, class name in a static reference, method name, etc.)
The symbol => is used to separate an expression (on the left) from its return value (on the right).
An ellipsis (...) indicates that the previous argument may be repeated any number of times. The description will indicate whether one instance is required.
Oi.drop(object)
Oi.drop(int)
This method removes an object from Oi. Any index for that object previously retrieved via o2i will no longer be valid.
If object is passed, that object (if tracked by Oi) will be removed. If that object is not currently tracked by Oi, nothing happens.
If int is passed, then the object whose index is int will be removed. If the index is not valid, nothing happens.
Oi.i2o(int) => object
This method returns the object whose Oi integer value is int, or ^null if int does not correspond to an object currently being tracked by Oi.
Oi.o2i(object) => int
This method returns an integer that uniquely identifies object within Oi. If Oi is already tracking the object in question, its index will be returned. If not, the object will be added to Oi's internal array and the new index will be returned. The index of previously dropped objects may be reused. The value will be in the range of 0 through the number of objects currently being tracked by Oi minus one.