Skip to content

$QSubscript()

$QSubscript()

Returns a component of a variable name.

The format of the $QSUBSCRIPT function is:

$QS[UBSCRIPT](namevalue, intexpr)
  • The namevalue has the form of an evaluated subscripted or unsubscripted global or local variable name.

  • The intexpr selects the component of the name as follows:

    • -2 : is reserved but may be “error”,
    • -1 : for environment,
    • 0 : for the unsubscripted name,
    • 1 : for the first subscript,
    • 2 : for the second subscript, and so on.
  • If the second argument selects a component that is not part of the specified name, $QSUBSCRIPT() returns an empty string ("").

Examples of $QSUBSCRIPT()

Example:

Assume that X is defined as in the “Examples of $Qlength()” earlier in this chapter;

write X
X="^|""XXX""|ABC(1,2,3,5,6)"
GTM>write $qsubscript(X,-2)
error
GTM>WRITE $qsubscript(X,-1)
XXX
GTM>WRITE $qsubscript(X,0)
^ABC
GTM>WRITE $qsubscript(X,1)
1
GTM>WRITE $qsubscript(X,4)
5
GTM>WRITE $qsubscript(X,7)
""