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.
Object-Specific ObjectScript Features<br />
ClassMethod SelfAdd(Arg1 As %Integer)<br />
{<br />
Do ##super(Arg1)<br />
Write !<br />
Write Arg1 + Arg1 + Arg1<br />
Quit<br />
}<br />
then its output is:<br />
>Do ##Class(MyClass.Down).SelfAdd(2)<br />
2<br />
4<br />
8<br />
><br />
A more generic way to refer to other methods are the $ZObjMethod and $ZObjClassMethod<br />
functions, which are for instance and class methods, respectively. These provide a mechanism<br />
for referring to packages, classes, and methods programmatically.<br />
21.5 i% Syntax<br />
When you instantiate a class with a persistent property, <strong>Caché</strong> creates what is called an<br />
instance variable, which holds the property's value. When you set or refer to a property value,<br />
<strong>Caché</strong> invokes what are called “Get” and “Set” accessor methods, which ultimately refer<br />
to the instance variable. The accessor methods have names of the form Get<br />
and Set, where is the name of property being accessed.<br />
For example, if a class contains an LName property of type %String:<br />
Property LName As %String;<br />
then displaying the property's value for a particular instance<br />
> Write MyClass.Up.LName<br />
Pepperidge<br />
actually goes through the MyClass.Up.LNameGet accessor method to get the value from<br />
the property's instance variable.<br />
Similarly, the typical call to set a property's value:<br />
>Set MyClass.Up.LName = "Blutarsky"<br />
actually invokes the MyClass.Up.LNameSet method, passing in the new value to set the<br />
value of the instance variable and, thereby, that of LName.<br />
184 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>