Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
There are two types of array properties: arrays of data types and arrays of objects. Arrays of<br />
objects can contain either embedded or persistent objects. These arrays are populated in<br />
similar but slightly different ways.<br />
10.4.4.1 Populating Arrays of Data Types<br />
To add an element to an array of data types use the following syntax:<br />
Do oref.PropertyName.SetAt(data,key)<br />
where oref is the OREF of the specific object to associate the data with, PropertyName is the<br />
name of the list property, data is the actual data, and key is the key associated with the new<br />
element.<br />
For example, to add a new color to an array of RGB values accessed by color name in a<br />
Palette object, use the following code:<br />
Do palette.Colors.SetAt("255,0,0","red")<br />
where palette is the OREF containing the array, Colors is the name of the array property, and<br />
“red” is the key to access the value “255,0,0” .<br />
10.4.4.2 Populating Arrays of Embedded <strong>Objects</strong><br />
To add an element to an array of embedded objects, create the new object, populate it, then<br />
use the following syntax to add the object to the array:<br />
Do oref.PropertyName.SetAt(ElementOref,key)<br />
where oref is the OREF of the specific object to associate the data with,PropertyName is the<br />
name of the list property,ElementOref is the OREF of the new element, and key is the key<br />
associated with the new element. For example, to add a vaccination record accessed by date<br />
to a Vaccination array in a Patient object, use the following code:<br />
Do pat.Vaccination.SetAt(vac,"04/08/99")<br />
where pat is the OREF of the Patient object and “04/08/99” is the key to access the Vaccination<br />
object with the OREFvac.<br />
10.4.4.3 Populating Arrays of Persistent <strong>Objects</strong><br />
Modifying <strong>Objects</strong><br />
The syntax described for populating arrays of embedded objects also applies to arrays of<br />
persistent objects, if the objects are already in memory. In addition, you can populate arrays<br />
of persistent objects with objects that are not in memory. Use the following syntax to add the<br />
object to the array:<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 79