$Get()

Examples of $GET()

The $GET function returns the value of a local or global variable if the variable has a value. If the variable has no value, the function returns a value specified by an optional second argument, and otherwise returns a null string.

The format for the $GET function is:

    $G[ET](glvn[,expr])
    

M defines $GET(x,y) as equivalent to:

    $SELECT($DATA(x)[0:y,1:x)
    

and $GET(x) as equivalent to:

    $GET(x,"")
    

$GET() provides a tool to eliminate separate initialization of variables. This technique may provide performance benefits when used to increase the density of a sparse global array by eliminating nodes that would otherwise hold absent optional information. On the other hand, some uses of one argument $GET() can mask logic problems.

GT.M has a "NOUNDEF" mode of operation, which treats all variable references as if they were arguments to a one argument $GET(). The VIEW command and GTM$DEFAULTS controls "NOUNDEF" mode. For more information about GTM$DEFAULTS, refer to the "Program Development Cycle" chapter in this manual.