Using Caché Multi-Dimensional Storage - InterSystems ...
Using Caché Multi-Dimensional Storage - InterSystems ...
Using Caché Multi-Dimensional Storage - InterSystems ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Using</strong> <strong>Multi</strong>dimensional <strong>Storage</strong> (Globals)<br />
color = ^Data("Color") ' assign to a local variable<br />
Print ^Data("Color") ' use as an argument to a command<br />
MyMethod(^Data("Color")) ' use as a function argument<br />
<strong>Using</strong> <strong>Caché</strong> ObjectScript:<br />
SET color = ^Data("Color") ; assign to a local variable<br />
WRITE ^Data("Color")<br />
; use as a command argument<br />
SET x=$LENGTH(^Data("Color")) ; use as a function parameter<br />
3.4.1 The $GET Function<br />
Within <strong>Caché</strong> ObjectScript, you can also get the value of a global node using the $GET<br />
function:<br />
SET mydata = $GET(^Data("Color"))<br />
This retrieves the value of the specified node (if it exists) or returns the null string ("") if the<br />
node is undefined. You can use the optional second argument of $GET to return a specified<br />
default value if the node is undefined.<br />
3.4.2 The WRITE, ZWRITE, and ZZDUMP Commands<br />
You can display the contents of a global or a global subnode by using the various <strong>Caché</strong><br />
ObjectScript display commands. The WRITE command returns the value of the specified<br />
global or subnode as a string. The ZWRITE command returns the name of the global variable<br />
and its value, and each of its descendant nodes and their values. The ZZDUMP command<br />
returns the value of the specified global or subnode in hexadecimal dump format.<br />
3.5 Traversing Data within a Global<br />
There are a number of ways you can traverse (iterate over) data stored within a global.<br />
3.5.1 The $ORDER (Next / Previous) Function<br />
The <strong>Caché</strong> ObjectScript $ORDER function (and its <strong>Caché</strong> Basic equivalent: Traverse)<br />
allows you to sequentially visit each node within a global.<br />
The $ORDER function returns the value of the next subscript at a given level (subscript<br />
number). For example, suppose you have defined the following global:<br />
20 <strong>Using</strong> <strong>Caché</strong> <strong>Multi</strong>-<strong>Dimensional</strong> <strong>Storage</strong>