Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

$QSUBSCRIPT

M[UMPS] by Example

Introduced in the 1995 ANSI M[UMPS] language standard.

This function returns the value of a subscript in a name- reference.

Assume that X is defined as in the example with the function $QLength (X="^|""XXX""|ABC(1,2,3,5,6)").

Reference   Value
$QSubscript(X,–2)   reserved (may be error)
$QSubscript(X,–1)   "XXX"
$QSubscript(X,0)   "^ABC"
$QSubscript(X,1)   "1"
$QSubscript(X,2)   "2"
$QSubscript(X,3)   "3"
$QSubscript(X,4)   "5"
$QSubscript(X,5)   "6"
$QSubscript(X,6)   ""
$QSubscript(X,7)   ""

$QSubscript is a lot easier to use than $Piece with parentheses and commas as separators, especially when there are string-subscripts that contain commas and quotes:

Set Q="""",C=","

Reference   Value
Set X=$NAme(^ABC(1,Q,C,9_Q_C_8))   X="^ABC(1,"""""""","","",""9"""",8"")"
(or, without all those confusing double quotes, and using {curly braces} instead to delimit strings)
^ABC(1,{"},{,},{9",8})
$QSubscript(X,1)   "1"
$QSubscript(X,2)   """"
$QSubscript(X,3)   ","
$QSubscript(X,4)   "9"",8"

Note that this function only operates on the string that contains the name of a variable. The variable that is identified in this string is never accessed by this function. Therefore, this function only affects the naked indicator if the string in question is stored in a global variable.

Set ^NUM(5,6)=2
Set ^FOO(2,4,6)=$NAme(^A(1,"abc",9))

Reference   Value
$QSubscript(^FOO(2,4,6),^NUM(5,6))   "abc"

in this example, the naked indicator becomes "^NUM(5,".

For additional examples of this function, see the function $NAme.

Approved for addition in a future M[UMPS] Language Standard:

It is allowed to specify a reference to $QSubscript on the left hand side of the equal sign in a Set command.

Set N="^|""where""|ABC(11,22,33)"

Reference   Value
Set $QSubscript(N,–1)="A"   N="^|""A""|ABC(11,22,33)"
Set $QSubscript(N,0)="xxx"   N="^|""A""|xxx(11,22,33)"
Set $QSubscript(N,2)=9   N="^|""A""|xxx(11,9,33)"
Set $QSubscript(N,10)=123   N="^|""A""|xxx(11,9,33,"","","","","","",123)"
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 12-Sep-2014, 13:28:30.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)