M[UMPS] Functions - $F[IND]
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"
SET TEXT="ABCATEXTYZ"
SET Y="B"
SET Z="1.2W",Y="B"
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,
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,
This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.
This document describes the various operators that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).
The information in this document is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.
In this document, information is included that will appear in future standards.
The MDC cannot guarantee that these 'next' standards will indeed appear.
It is part of a book by Ed de Moel that is published under the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.
This document describes the various operators that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).
The information in this document is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.
In this document, information is included that will appear in future standards.
The MDC cannot guarantee that these 'next' standards will indeed appear.