Skip to main content

Value and Existence, and the $Data Function

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 feature of ObjectScript arrays: locations can exist without having assigned values.

There is an 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.


USER>write $data(A) ; has value and descendants
USER>write $data(A(3)) ; has descendants only
USER>write $data(A(3, 3)) ; has value only
USER>write $data(A(3, 5)) ; doesn't exist
FeedbackOpens in a new tab