Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer


M[UMPS] by Example

Right Hand Pointer

Approved for inclusion in a future M[UMPS] language standard as part of the library for String Handling.

This function returns a translated version of the value of its parameter.

This function could be used to reduce multiple separators to single ones:

; Two blanks will be reduced to a single one
Set SPEC(1,1)=" ",SPEC(1,2)=" "
; translate all relevant separators into blanks
Set X=$TRanslate(X,"!?,.;:()"," ")
; and reduce multiple blanks to singletons

A soundex algorithm for English names:

1. Remove non-alpha and convert lower case to upper case
2. Examine first letters
PH --> F
CE --> S
KN --> N
WR --> R
C --> K
3. Ignore all other vowels (A, E, I, O and U)
4. Then replace
MP --> M
ST --> S
DG --> D
TCH --> CH
GHT --> HT
5. Then make the following equivalent
B, F, P and V
C, G, J, K, Q, S, X and Z
D and T
M and N
6. Finally, remove multiple consecutive occurrences of the same character

 Set LOW="abcdefghijklmnopqrstuvwxyz"
 Set A=$TRanslate(A,LOW_"-., ()'",UP)
 For I=1:1:5 Set C(I,1)=$Piece("PH C CE KN WR"," ",I)
 For I=1:1:5 Set C(I,2)=$Piece("F. K S. N. R."," ",I)
 Set I=$%REPLACE^STRING($Extract(A,1,2),.C)
 Set $Extract(A,1,2)=I
 Set A=$TRanslate(A,"AEIOUY.")
 For I=1:1:5 Do
 . Set C(I,1)=$Piece("MP ST DG TCH GHT"," ",I)
 For I=1:1:5 Do
 . Set C(I,2)=$Piece("M. S. D. CH. HT." ",I)
 Set A=$TRanslate(A,S1,S2)
 For I=1:1:26 Do
 . Set C(I,1)=$Char(64+I,64+I)
 . Set C(I,2)=$Char(64+I)
 Quit A

The MDC has approved code to approximate the return value of this function. Implementors are encouraged to provide more accurate and efficient code).
Click here for $%PRODUCE^STRING sample code to view or download the code for this function.
Click here for AllFunctions to view or download the code for all M[UMPS] Library Functions.

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-2017 MUMPS Development Committee;
Copyright © Examples: 1995-2017 Ed de Moel;
Copyright © Annotations: 2003-2017 Jacquard Systems Research.

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, 12:56:43 .

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