Setting Index value of an array object

dwhite

Member
I'm not sure if this is a dumb question or not but say I have an object that I've built and I want to put it into an array like so:


DEFINE VAR myObject AS SomeObject EXTENT 2.

myObject[1] = NEW SomeObject(311).
myObject[2] = NEW SomeObject(211).

and the 311 and 211 are unique id's tied to my object.

Instead of referencing the object like so:

MESSAGE myObject[1]:ObjectProperty.

I'd like to reference it like this:

MESSAGE myObject[311]:ObjectProperty.

Is this possible? If so, how?


I am using 10.2.B by the way.
 
To reference by the ID, you need to use the ID as the index. Probably, you want to use a temp-table instead of an array and put the ID and the object in the temp-table.

Of course, this sounds a whole lot like something that one would do to express a one to many relationship between two classes, so you might want to check out http://www.oehive.org/CollectionClassesForOORelationships for ideas on how to handle that.
 
Back
Top