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 />
where oref is the OREF of the specific object to associate the data with,PropertyName is the<br />
name of the list property, and data is the actual data. For example, you can change a person's<br />
favorite colors from “red” , “blue” , and “green” to “red” , “yellow” , and “green” using<br />
the following code:<br />
Do person.FavoriteColors.SetAt("yellow",2)<br />
where person is the OREF of the Person object.<br />
You can insert data into slot n using the following syntax:<br />
Do oref.PropertyName.InsertAt(data,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 data is the actual data. Again, insert a new list item increments<br />
the value of all previously-existing list items. For example, you can change a person's favorite<br />
colors from “red” , “blue” , and “green” to “red” , “yellow” , “blue” , and “green” using<br />
the following code:<br />
Do person.FavoriteColors.InsertAt("yellow",2)<br />
where person is the OREF of the Person object.<br />
10.4.3.2 Populating Lists of Embedded <strong>Objects</strong><br />
You can populate a list of objects in several ways. You can create a new object, populate it,<br />
then add it to the end of the list using the following syntax:<br />
Do oref.PropertyName.Insert(ItemOref)<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 ItemOref is the OREF of the object. For example, you can add<br />
a new vaccination record to a Patient object using the following code:<br />
Do pat.Vaccination.Insert(vac)<br />
where pat is the OREF of the Patient object and vac is the OREF of the Vaccination object.<br />
You can create a new object, populate it, then change an existing slot n using the following<br />
syntax:<br />
Do oref.PropertyName.SetAt(ItemOref,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 ItemOref is the OREF of the object. For example, you can<br />
76 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>