Skip to main content

Value and Existence, and the Exists() Function

generated description: treedone.gif

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 assignments created their children. Print prints the empty string for a variable or node without a value. They can remain valueless, or you can give them values later on. This demonstrates another unique feature of Basic arrays: locations can exist without having assigned values.

There is a function that allows you to probe the nodes of a tree and learn about their status: Exists(). If Exists() returns a non-zero result, the node exists in some way. To clarify your code, compare the value of the Exists() with these constants (use your browser's Back button to return here).

A = 4 : A(3,3) = 4
println exists(A), " means: value and descendants, equals ", _
        vbHasArray + vbHasValue
println exists(A(3)), " means: descendants only, equals ", _
println exists(A(3, 3)), " means: value only, equals ", _
println exists(A(3, 5)), " means: doesn't exist"
FeedbackOpens in a new tab