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

$%REPLACE^STRING

M[UMPS] by Example

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.

Suppose that it is necessary to print German umlauted characters on a printer that is not able to produce such characters, in such a case the Umlaut on the character is usually replaced by the vowel "e" following the character. Hence:

Kill SPEC
Set SPEC(1,1)="ä",SPEC(1,2)="ae"
Set SPEC(2,1)="ö",SPEC(2,2)="oe"
Set SPEC(3,1)="ü",SPEC(3,2)="ue"
Set SPEC(4,1)="Ä",SPEC(4,2)="AE"
Set SPEC(5,1)="Ö",SPEC(5,2)="OE"
Set SPEC(6,1)="Ü",SPEC(6,2)="UE"

Write $%REPLACE^STRING(X,.SPEC)

would write the text in X, with all umlauted characters translated into two characters.

The same function could be used for simplifying output-strings containing device-dependent functions:

Kill S
Set S(1,1)="<UP-ARROW>",S(1,2)=$Char(27)_"[A"
Set S(2,1)="<DOWN-ARROW>",S(2,2)=$Char(27)_"[B"
Set S(3,1)="<RIGHT-ARROW>",S(3,2)=$Char(27)_"[C"
Set S(4,1)="<LEFT-ARROW>",S(4,2)=$Char(27)_"[D"
Set S(5,1)="<ESCAPE>",S(5,2)=$Char(27)
Set S(6,1)="<LINE-FEED>",S(6,2)=$Char(10)
Set X=$%REPLACE^STRING(INPUT,.S)

would produce a value in X with some human readable device control commands translated into the code-sequences that would be sent to an external device.

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 $%REPLACE^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-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 14-Nov-2023, 21:34:03.

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