Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Using</strong> <strong>Objects</strong> with <strong>Caché</strong> ObjectScript<br />
the pet in the third slot in the list of pets owned by a person to a new dog using the following<br />
code:<br />
Do per.Pets.SetObjectAt(DogOid,3)<br />
where per is the OREF of the Person object and DogOid is the OID of the Dog object.<br />
You can insert an object into slot n using the following syntax:<br />
Do oref.PropertyName.InsertObjectAt(ItemOid,n)<br />
where oref is the OREF of the specific object to associate the data with, PropertyName is the<br />
name of the list property, and ItemOid is the OID of the object. Again, insert a new list item<br />
increments the value of all previously-existing list items. For example, you can add a new<br />
dog to the beginning of the list of pets owned by a person using the following code:<br />
Do per.Pets.InsertObject(DogOid,1)<br />
where per is the OREF of the Person object and DogOid is the OID of the Dog object.<br />
10.4.3.4 Modifying Properties of <strong>Objects</strong> in Lists<br />
Once an object has been associated with a particular slot, you can modify its properties as<br />
follows:<br />
Set oref.PropertyName.GetAt(n).ListPropertyName = data<br />
where oref is the OREF of the object containing the list; PropertyName is the name of the<br />
list property; the GetAt method finds and returns the value of the element specified by n; n<br />
is the slot in the list containing the object to update; ListPropertyName is the property to<br />
update; and data is the actual data to associate with the property.<br />
For example, to set the name of a person' s second pet, use the following code:<br />
Set per.Pets.GetAt(2).Name = "Rover"<br />
where per is the OREF of the Person object and Rover is the name of the pet.<br />
10.4.4 Modfiying Array Properties<br />
Arrays are unordered collections of information (unlike lists, which are ordered). An array<br />
consists of one or more name-value pairs, where the name of the element serves as a key and<br />
the value is data associated with that key. There is no syntactic difference between adding a<br />
new element and changing the data contained in an existing element.<br />
78 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>