Library Functions -- $%REPLACE^STRING

Approved for inclusion in a future ANSI 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 to view or download the code for this function. Click here to view or download the code for all M[UMPS] Library Functions.


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 library functions that are defined for the M[UMPS] programming language.

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.