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 />
Do rc.PurgeAll()<br />
where rc is the OREF of a ReportCard object.<br />
Similarly, you can execute the Exists class method of the %File class using the following<br />
code:<br />
Set exists = file.Exists("\temp\file.txt")<br />
where exists is the return value and file is the OREF of any %File object.<br />
10.1.5 Error Conditions<br />
When invoking a class or instance method, a runtime error can occur under the following<br />
conditions:<br />
• If you attempt to invoke a private method from outside of the object (that is, not from<br />
one of its other methods).<br />
• If you invoke a method that is not defined for a class or an object instance.<br />
• If you attempt to invoke a method for a class does not exist.<br />
10.2 Creating New <strong>Objects</strong><br />
The general syntax for creating new object instances is to use the class method %New:<br />
Set oref = ##class(Classname).%New()<br />
where oref is the OREF of the new object and Classname is the name of the class to create.<br />
Classname is case sensitive and may contain a package name.<br />
For example, to create a new Person object, use the following code:<br />
Set person = ##class(MyApp.Person).%New()<br />
where person is the OREF of the new Person object.<br />
You can pass an optional argument to the %New method. If present, this argument is passed<br />
to the object's %OnNew method. The use of this argument depends on the implementation<br />
of the specific class you are using.<br />
70 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>