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 />
10.1.1 About Return Values<br />
Some methods return a value when executed; others do not. If a method has a return value<br />
and your application does not need it, you can invoke it using the syntax for methods that do<br />
not return a value. To invoke a method without checking its return value, use the Do command;<br />
to invoke a method and check use the Set command. Examples of invoking instance methods<br />
each way appear in the section Executing Instance Methods; examples of invoking class<br />
methods each way appear in the section Executing Class Methods.<br />
10.1.2 Executing Instance Methods<br />
To execute a instance method, you must first create (or open from the database) an instance<br />
of an object.<br />
To execute an instance method, use syntax similar to either of the following lines of code:<br />
Do oref.MethodName(arglist)<br />
Set value = oref.MethodName(arglist)<br />
where oref is a reference to the relevant object that is already in memory (see the section<br />
“Referring to an Object—OREFs and OIDs” in the chapter on the <strong>Caché</strong> object model for<br />
more information on OREFs), MethodName is the name of the method to execute, and arglist<br />
is the list of arguments passed to the method. value, in the second line of code, is a local<br />
variable that receives the return value of the method.<br />
For example, to execute the Admit method of a Patient object use the following code:<br />
Do pat.Admit()<br />
where pat is the OREF of the desired Patient object.<br />
Similarly, to execute the SearchMedicalHistory method of a Patient object use the following<br />
code:<br />
Set result = pat.SearchMedicalHistory("MUMPS")<br />
where pat is the OREF of the desired Patient object and result holds the value returned by<br />
SearchMedicalHistory.<br />
68 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>