$Query()

Examples of $QUERY()

The $QUERY function returns the next subscripted local or global variable node name, independent of level, which follows the node specified by its argument in M collating sequence and has a data value.

The format for the $QUERY function is:

    $Q[UERY](glvn)        
    

$QUERY() provides a tool for scanning an entire array for nodes that have data values. Because $QUERY() can return a result specifying a different level than its argument, the result provides a full variable name. This contrasts with $ORDER(), which returns a subscript value. To access the data value at a node, a $ORDER() return can be used as a subscript; however, a $QUERY() return must be used with indirection. Because arrays tend to have homogeneous values within a level but not between levels, $QUERY() is more useful as a tool in utility programs than in application programs. The $QUERY() is useful in avoiding nested $ORDER loops.

Note that the standard does not unambiguously define the state of the naked reference indicator after a $QUERY(). While in GT.M after $QUERY(), the naked reference indicator reflects the $QUERY() argument, NOT its result.