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

$FIND

M[UMPS] by Example

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

This function returns information about whether and where a substring occurs in a string.

Assume that TEXT="ABCDABEFAD"

Reference   Value
Set Y=$Find(TEXT,"A")   2
Set Y=$Find(TEXT,"A",2)   6
Set Y=$Find(TEXT,"A",11)   11
Set Y=$Find(TEXT,"ABC",1)   4
Set Y=$Find(TEXT,"ABD")   0
Set Y=$Find(TEXT,"")   1
Set Y=$Find(TEXT,"",4)   4
Set T=TEXT
Set L=$Length(T)+1
Set Y=$Find(T,"",L)
  0

Set TEXT="ABCATEXTYZ"

Reference   Value
$Find(TEXT,"A")   2
$Find(TEXT,"B")   3
$Find(TEXT,"Z")   0
$Find(TEXT,"ABC")   4
$Find(TEXT,"TEXT")   9
$Find(TEXT,TEXT)   11
$Find("ABC","ABC")   4
$Find(TEXT,"A",1)   2
$Find(TEXT,"A",2)   5
$Find(TEXT,"A",4)   5
$Find(TEXT,"A",5)   0
$Find(TEXT,"A",100)   0
$Find(TEXT,"")   1
$Find(TEXT,"",4)   4
$Find(TEXT,"",10)   10

Set Y="B"

Reference   Value
$Find(TEXT,Y)   3

Set Z="1.2W",Y="B"

Reference   Value
$Find(TEXT,Y,Z)   3
$Find(TEXT,Y,2)   3

Examples with naked references:

$Find(VALUE,STRING)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=$Find(^(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,

$Find(VALUE,STRING,FROM)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=$Find(^(5,6),^(7,8),^(9,10))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. fetch ^(7,8) = ^ABC(1,5,7,8)
; 3. fetch ^(9,10) = ^ABC(1,5,7,9,10)
; 4. store ^(3,4) = ^ABC(1,5,7,9,3,4)
; naked indicator is now: ^ABC(1,5,7,9,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, 16:41:44.

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