Skip to content

$Qlength()

$Qlength()

Returns the number of subscripts in a variable name. The format is:

$QL[ENGTH] (namevalue)
  • The namevalue has the form of an evaluated subscripted or unsubscripted global variable.
  • $QLENGTH() returns a value which is derived from namevalue. If namevalue has the form NAME(s1, s2,…, sn), then the function returns n; if the name is unsubscripted, $QLENGTH() yields a length of zero (0).
  • $QLENGTH() only affects the naked indicator if the string in question is stored in a global variable.

Examples of $QLENGTH()

Example:

GTM>write $data(^|"XXX"|ABC(1,2,3,4))
0
GTM>set X=$name(^(5,6))
GTM>write $qlength(X)
5

The number of subscripts in x is 5. Notice that the name and the environment preceding it do not contribute to the count. Refer to $NAme() section earlier in this chapter for an understanding of the $NAME function.