Command: EXISTS
Command: DATA

Purpose: Determines whether or not a persistent array record exists on the GT.M or Caché system.

The hierarchical nature of the persistent arrays means that the definition of existence of a node is three-fold:

For this reason, this command may return more than a simple 1/0 (true/false) value:

For example, consider the following array:

myArray[1,"y","hello world"]="ok"
myArray[1,"z","hello world"]="not ok"

The EXISTS command will return the values shown for the following array references:

myArray: 11
myArray[1]: 10
myArray[1,"x"]: 1
myArray[1,"y"]: 11
myArray[1,"y","hello world"]: 1
myArray[1,"z"]: 10
myArray["x"]: 0


Argument No Description
1 The array node whose existence is to be determined. This takes the format:
You may specify no subscripts at all, in which case the top-level node is checked,eg:
Testing a value at the first level of subscripting would look like:
Testing a value at the second level of subscripting would look like:

Note that subscripts can be numeric or text. Text subscripts must be wrapped in double quote (") characters. Quoting of numeric subscripts is optional.


One-line response

Possible values are:


Client: EXISTS myArray
Server: :11
Client: EXISTS myArray[1]
Server: :10
Client: EXISTS myArray[1,"y"]
Server: :11
Client: EXISTS myArray["x"]
Server: :0

For those familiar with the native language of GT.M and Caché systems, these examples above are the equivalent of:

write $data(^myArray)
write $data(^myArray(1))
write $data(^myArray(1,"y"))
write $data(^myArray("x"))