docs.intersystems.com
ObjectScript Tutorial
Value and Existence, and the $Data Function
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

Of course, any node can have its value changed at any time. Note that not all the nodes in the tree have assigned values. Two in particular, A(3) and A(5,"D"), only have children. They were created only because Set statements created their children. They can remain valueless, or you can give them values later on. This demonstrates another unique feature of ObjectScript arrays: locations can exist without having assigned values. In other languages, if a variable exists, it always has a value.
There is a very important function that allows you to probe the nodes of a tree and learn about their status: $Data. If $Data returns a non-zero result, the node exists in some way.
SAMPLES>write $data(A) ; has value and descendants
11
SAMPLES>write $data( A(3) ) ; has descendants only
10
SAMPLES>write $data( A(3, 3) ) ; has value only
1
SAMPLES>write $data( A(3, 5) ) ; doesn't exist
0


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA