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

$LENGTH

M[UMPS] by Example

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

This function returns information about the length of a string.

Reference   Value
$Length("ABC")   3
$Length("ABCD354")   7

Set X="ABCD"

Reference   Value
$Length(X)   4
$Length("")   0 (zero)

Set X=""

Reference   Value
$Length(X)   0 (zero)

Set X="ABC"

Reference   Value
$Length(X)   3

Set X="123456789"

Reference   Value
$Length(X)   9

Set X=""

Reference   Value
$Length(X)   0

Addition in the 1990 ANSI M[UMPS] language standard (count pieces separated by value of second parameter):

Reference   Value
$Length("A.B.C",".")   3
$Length("A.B.C","-")   1
$Length("A-A-A-A","A-")   4, not 3.5

The value of $Length("abababaaba","aba") is seemingly open to interpretation, after all, the string "abababaaba"can be segmented in various ways, and the function value would vary with the interpretation

Because the language standard stipulates that in all cases where a choice exists, strict left-to-right evaluation prevails, the second interpretation is the one that is endorsed by the language standard.

Examples with naked references:

$Length(VALUE)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=$Length(^(5,6))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. store ^(3,4) = ^ABC(1,5,3,4)
; naked indicator is now: ^ABC(1,5,3,

$Length(VALUE,SUBSTR)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=$Length(^(5,6),^(7,8))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. fetch ^(7,8) = ^ABC(1,5,7,8)
; 3. store ^(3,4) = ^ABC(1,5,7,3,4)
; naked indicator is now: ^ABC(1,5,7,3,

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 13-Sep-2014, 17:19:47.

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