Special characters

In this chapter, the terms unary operator and binary operator will be used. In this context, the meaning of these terms is to be taken in their mathematical sense: a unary operator is an operator that works on one operand, a binary operator is an operator that works on two operands.


space ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~


Space (" ")

ASCII code 32.

This character separates commands from surrounding information.
At the beginning of a program line, there may be a label with a parameter list. There is always a space that indicates the start of the line, and then there may be commands. Each command is separated from its argument(s) by one space, and if there are multiple commands on a line, there is at least one space between the last argument of one command and the next command.
 SET X=1 WRITE "Hello."

Addition in the 1990 ANSI M[UMPS] language standard:

The number of spaces at the start of a line may be more than one.
The number of spaces between a command-argument and the next command may be larger than one.
   SET X=1   WRITE "Hello."

Approved for addition in a future ANSI M[UMPS] language standard:

Spaces may occur at the end of a line.

   SET X=1   WRITE "Hello."   


Exclamation mark ("!")

ASCII code 33.

This character may be used as a binary 'or' operator.
IF (X>2)!(B<9)

This character may be used as a 'new-line' indicator in an argument of a READ or WRITE command.
READ !?5,"What is your age? ",AGE
WRITE !?10,"That is not an appropriate question."

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used as a binary 'exclusive or' operator.
IF (X>2)!!(B<9)


Quotes, also known as inch sign ("""")

ASCII code 34.

Many people call this character 'double quote'. In this document, the character ' is called apostrophe, and the character " is called quotes.

Quotes delimit strings. When a quotes-character needs to be embedded in a string, it needs to be written twice.
SET X="This is a string."
SET Y="This ""string"" contains quotes."


Number sign, also known as pound sign ("#")

ASCII code 35.

This character may be used as a binary 'modulo' operator.
SET THISHOUR=$PIECE($HOROLOG,",",2)\60\60
SET THEN=THISHOUR+8#24

This character may be used as a 'form-feed' indicator in an argument of a READ or WRITE command.
IF LINES>PAGESIZE WRITE #

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used in the argument of a READ command to indicate the maximum length for the value to be read:
READ X#20


Dollar sign ("$")

ASCII code 36.

This character preceeds the name of intrinsic language elements (variables and functions).
$IO, $HOROLOG, $ASCII, $FIND, etcetera.

Additions in the 1990 ANSI M[UMPS] language standard:

This character is used in a reference to an extrinsic variable:
SET X=$$LABEL^ROUTINE

This character is used in a reference to an extrinsic function:
SET X=$$LABEL^ROUTINE(PARA,METERS)

Additions in the 1995 ANSI M[UMPS] language standard:

This character preceeds the name of structured system variables.
^$CHARACTER, ^$ROUTINE, etcetera.

This character is used in a reference to an external function call.
SET X=$&CADD^MATH("1%0","0%1")

Approved for addition in a future ANSI M[UMPS] language standard:

This character is used to in a reference to a standard library function.
SET X=$%CADD^MATH("1%0","0%1")


Percent sign ("%")

ASCII code 37.

This character may occur as the first character in the name of a M[UMPS] entity (local variable, global variable, routine, label in a routine)

Addition in the 1995 ANSI M[UMPS] language standard:

This character is used in the interpretation of strings as complex numbers: real and imaginary parts are separated by a percent sign.
SET X=$&CADD^MATH("1%0","0%1")

Approved for addition in a future ANSI M[UMPS] language standard:

This character is used to identify a function reference as a reference to a standard library function.
SET X=$%CADD^MATH("1%0","0%1")


Ampersand ("&")

ASCII code 38.

This character may be used as a binary 'and' operator.
IF (X>2)&(B<9)

Additions in the 1995 ANSI M[UMPS] language standard:

This character is used in the prefix that identifies an "external" routine:
DO &XMUMPS.Exit(123)
SET X=$&CADD^MATH("1%0","0%1")

This character may be used to introduce an embedded 'foreign language' program:
&SQL(SELECT * FROM SALES WHERE CONTACT = "Jones")

Approved for addition in a future ANSI M[UMPS] language standard.

Names of external language processors will be case-insensitive.

&sql(cursor A on EMPLOYEES)

has the same meaning as the same command starting with &SQL

Implementors may add external language processors; the names for such implementation-specific processors will start with the letter "Z".

The parameter list in a call to an external language processor may be empty.


Apostrophe, also known as foot sign ("'")

ASCII code 39.

Many people call this character 'single quote'. In this document, the character ' is called apostrophe, and the character " is called quotes.

This character may be used as a unary 'not' operator.
IF '(X>2)

This character may be used to negate the meaning of other operators. The following pairs of expression are equivalent by definition:

Is equal to: X'=2 is the same as '(X=2)
Is greater than: X'>2 is the same as '(X>2)
Is less than: X'<2 is the same as '(X<2)
Is less than or equal to: X'<=2 is the same as '(X<=2)
Is greater than or equal to: X'>=2 is the same as '(X>=2)
Matches pattern: X'?2N is the same as '(X?2N)
Contains: X'[2 is the same as '(X[2)
Follows: X']2 is the same as '(X]2)
Follows or equal to: X']=2 is the same as '(X]=2)
Collates after: X']]2 is the same as '(X]]2)
Collates after or equal to: X']]=2 is the same as '(X]]=2)


Left parenthesis ("(")

ASCII code 40.

This character may be used in conjunction with a matching right parenthesis to indicate a priority of evaluation.
SET X=12+(3*4)

This character may be used in conjunction with a matching right parenthesis to delimit lists of subscripts from names of variables.
SET X=NAME(3,"ABC",2)

This character may be used in conjunction with a matching right parenthesis to delimit parameter lists of intrinsic functions.
SET X=$ASCII("ABC",2)

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used in conjunction with a matching right parenthesis to delimit parameter lists of subroutines, extrinsic variables and extrinsic functions.
DO LABEL^ROUTINE(A,12,.X)
LABEL(ONE,TWO,THREE) ; 3rd parameter by reference
SET X=$$VAR
SET Y=$$FUNCT(A,12)
JOB ENTRY^PROGRAM(A,B,C)

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used in conjunction with a matching right parenthesis to delimit names of variables to which a value may be assigned in the context of the "find pattern match" operator.
IF '(X?4N(ITEM)1","1.3N(QUANT(ITEM)) DO ...


Right Parenthesis (")")

ASCII code 41.

This character may be used in conjunction with a matching left parenthesis to indicate a priority of evaluation.
SET X=12+(3*4)

This character may be used in conjunction with a matching left parenthesis to delimit lists of subscripts from names of variables.
SET X=NAME(3,"ABC",2)

This character may be used in conjunction with a matching left parenthesis to delimit parameter lists of intrinsic functions.
SET X=$ASCII("ABC",2)

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used in conjunction with a matching left parenthesis to delimit parameter lists of subroutines, extrinsic variables and extrinsic functions.
DO LABEL^ROUTINE(A,12,.X)
LABEL(ONE,TWO,THREE) ; 3rd parameter by reference
SET X=$$VAR
SET Y=$$FUNCT(A,12)
JOB ENTRY^PROGRAM(A,B,C)

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used in conjunction with a matching left parenthesis to delimit names of variables to which a value may be assigned in the context of the "find pattern match" operator.
IF '(X?4N(ITEM)1","1.3N(QUANT(ITEM)) DO ...


Asterisk, also known as star ("*")

ASCII code 42.

This character may be used as a binary 'multiplication' operator.
SET X=3*4

This character may be used as a binary 'exponentiation' operator.
SET X=4**3

This character may be used in READ commands to designate that a single character is to be read from the current device. Note that, although the syntax READ *X is standardized, the result of this command is implementation specific and, within an implementation, device specific.

Typically, the result of a command like READ X will be that the variable X will be set to an integer value that corresponds to the code of the character being transmitted. If a terminator character (or an "escape sequence") is transmitted, it is strongly implementation specific what the value of X will be.

This character may be used in WRITE commands to designate that a special action is to be performed on the current device. Note that, although the syntax WRITE *X is standardized, the result of this command is implementation specific and, within an implementation, device specific.

Typically, the result of a command like WRITE *VALUE will be that the character, whose code is equal to the integer interpretation of VALUE will be written to the current device. In some implementations, however WRITE *5 might rewind a magnetic tape, and WRITE *1 might write a file-label, etcetera.


Plus sign ("+")

ASCII code 43.

This character may be used as a unary 'numeric interpretation' operator.
SET X=+"5 apples"

This character may be used as a binary 'addition' operator.
SET X=3+4

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used to indicate addition of a name to the LOCK table.
LOCK +NAME


Comma (",")

ASCII code 44.

This character may be used to separate command arguments.
SET X=1,Y=2,Z=3

This character may be used to separate parameters of intrinsic functions.
SET X=$CHAR(65,66,67)

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used to separate parameters of subroutines and extrinsic functions.
DO LABEL^ROUTINE(A,12,.X)
LABEL(ONE,TWO,THREE) ; 3rd parameter by reference
SET Y=$$FUNCT(A,12)
JOB ENTRY^PROGRAM(A,B,C)

Addition in the 1995 ANSI M[UMPS] language standard:

This character may be used to separate various alternate pattern match options.
IF X?1N2(2U,1P,3N)1P2A


Minus sign, also known as hyphen or dash ("-")

ASCII code 45.

This character may be used as a unary 'negative numeric interpretation' operator.
SET X=-"5 apples"
SET X=---++-4.23

This character may be used as a binary 'subtraction' operator.
SET X=3-4

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used to indicate removal of a name from the LOCK table.
LOCK -NAME


Period, also known as point or dot (".")

ASCII code 46.

This character may be used in numbers to separate the integral part of a number from its decimal fraction.
SET X=12.345

Addition in the 1990 ANSI M[UMPS] language standard:

This character may be used in a parameter list (actuallist) to indicate that a parameter is passed by reference.
DO LABEL^ROUTINE(A,12,.X)

This character may be used to indicate that a line in a routine is part of a block of code that may only be invoked by means of an argumentless DO command.
SET K="" FOR  SET K=$ORDER(^D(K)) QUIT:K=""  DO
. SET L="" FOR  SET L=$ORDER(^D(K,L)) QUIT:L=""  DO
. . ; process one occurrence of ^D(K,L)
. . QUIT
. QUIT

Approved for addition in a future ANSI M[UMPS] language standard:

The period is introduced as the separator between parts of the name of a property or a method of an object. The part "to the left" of the period must be a handle or pointer to an object, the part "to the right" is the name of a property or method of that object (possibly iteratively).

DO word.Insert("Hello World.")
executes the method Insert of the object that is accessible through the value of local variable word.

SET word.bold=1
accesses the object that is accessible through the value of local variable word and sets its property bold to 1 (true).

SET word.Application.Document.PageSetup.PageWidth=11*inch
accesses a series of objects, and eventually sets the property of one object to a new value. The first object is the one that is accessed through the value of local variable word. For this object, the value of the property Application is fetched; this property is a pointer to another object. For that object, the value of the property Document is fetched; this property is a pointer to another object. For that object, the value of the property PageSetup is fetched; this property is a pointer to another object. For that object, finally, the value of its property PageWidth is set to the scalar value 11*inch.


Forward slash ("/")

ASCII code 47.

This character may be used as a 'division' operator.
SET X=3/4

Addition in the 1995 ANSI M[UMPS] language standard:

This character may be used to introduce a special formatting function in an argument of a READ or WRITE command.
WRITE /CUP(1,20) ; Position cursor
WRITE /SGR(1) ; Turn boldface on


Colon (":")

ASCII code 58.

This character may be used to separate commands and arguments from a 'postcondition' that indicates whether the command or argument is to be executed.
SET:A>5 X=99
GOTO LARGE:X>100,TINY:X>5,SMALL:X>50,AVERAGE

This character may be used to separate entities within arguments.
FOR I=1:1:4
LOCK NAME:TIME

Addition in the 1984 ANSI M[UMPS] language standard:

This character may be used to separate conditions and values in the parameterlist of the function $SELECT.
SET A=$SELECT(X>100:"Large",X<5:"Tiny",1:"Average")


Semicolon (";")

ASCII code 59.

This character may be used to introduce a comment.
SET HOURS=24 ; Initialize to full day


Left angle bracket, also known as less than sign ("<")

ASCII code 60.

This character may be used as a binary 'is less than' operator.
IF X<5

This character may be used as part of a binary 'is not less than' operator.
IF X'<5

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used as part of a binary 'is less than or equal to' operator.
IF X<=5

This character may be used as part of a binary 'is not less than or equal to' operator.
IF X'<=5


Equals sign ("=")

ASCII code 61.

This character may be used as an 'assignment' operator.
SET X="Look here!"

This character may be used as a binary 'is equal to' operator.
IF X=5

This character may be used as part of a binary 'is not equal to' operator.
IF X'=5

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used as part of a binary 'is less than or equal to' operator.
IF X<=5

This character may be used as part of a binary 'is not less than or equal to' operator.
IF X'<=5

This character may be used as part of a binary 'is greater than or equal to' operator.
IF X>=5

This character may be used as part of a binary 'is not greater than or equal to' operator.
IF X'>=5


Right angle bracket, also known as greater than sign (">")

ASCII code 62.

This character may be used as a binary 'is greater than' operator.
IF X>5

This character may be used as part of a binary 'is not greater than' operator.
IF X'>5

Approved for addition in a future ANSI M[UMPS] language standard:

This character may be used as part of a binary 'is greater than or equal to' operator.
IF X>=5

This character may be used as part of a binary 'is not greater than or equal to' operator.
IF X'>=5


Question mark ("?")

ASCII code 63.

This character may be used as a binary 'pattern match' operator.
IF X?1A3.5N

This character may be used as a 'tabulation' indicator in an argument of a READ or WRITE command.
READ !?5,"What is your age? ",AGE
WRITE !?10,"That is not an appropriate question."


At sign ("@")

ASCII code 64.

This character may be used as a unary 'indirection' operator.
SET NAME="ABC",X=123+@NAME+456
SET ARGU="X=123+456",@ARGU
SET ARRAY="^CUSTOMER("_CUSTID_")",@ARRAY(1)=55


Left square bracket ("[")

ASCII code 91.

This character may be used as a binary 'contains' operator.
IF ALPHABET["KLM"


Backward slash ("\")

ASCII code 92.

This character may be used as a binary 'integer division' operator.
SET SECONDS=$PIECE($HOROLOG,",",2)
SET DISPLAY=SECONDS\3600_":"_(SECONDS\60#60)


Right square bracket ("]")

ASCII code 93.

This character may be used as a binary 'follows' operator.
IF NEXT]PREVIOUS

Addition in the 1995 ANSI M[UMPS] language standard:

This character may be used in a binary 'sorts after' operator.
IF NEXT]]PREVIOUS


Caret, also known as circumflex ("^")

ASCII code 94.

This character preceeds the name of global variables and routines.
DO ^%G
SET ^PATIENT(ID,1)=AGE_"|"_BRTHDATE

Note that the caret character precedes names. It is not counted as a character when determining the length of a name.

Addition in the 1995 ANSI M[UMPS] language standard:

This character preceeds the name of structured system variables.
^$CHARACTER, ^$ROUTINE, etcetera


Underscore ("_")

ASCII code 95.

This character may be used as a binary 'concatenate' operator.
SET ^PATIENT(ID,1)=AGE_"|"_BRTHDATE


Grave ("`")

ASCII code 96.

This character has currently no syntactic meaning in M[UMPS].


Left curly brace ("{")

ASCII code 123.

This character has currently no syntactic meaning in M[UMPS].


Vertical bar ("|")

ASCII code 124.

Addition in the 1995 ANSI M[UMPS] language standard.

This character may be used to delimit an environment specification.
MERGE ^|HERE|PATIENT=^|ACROSS|PATIENT


Right curly brace ("}")

ASCII code 125.

This character has currently no syntactic meaning in M[UMPS].


Tilde ("~")

ASCII code 126.

This character has currently no syntactic meaning in M[UMPS].


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 possible meanings that the various punctuation characters may have, according to the various M[UMPS] standards.

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.