\$ASCII

M[UMPS] by Example

Introduced in the 1977 ANSI M[UMPS] language standard.

This function returns the internal code number for a character in a string.
The standard defines a one-to-one correspondence between the codes 0 through 127 and the characters from the (7-bit) ASCII set. Code numbers >127 are character-set-specific; code numbers <0 do not indicate valid characters. The special value –1 indicates a reference to a character that does not occur in the string that is passed as the first parameter.

Assume that X="ABCDE"

Reference Value Remarks
\$ASCII(X) 65
\$ASCII(X,1) 65 "A"
\$ASCII(X,2) 66 "B"
\$ASCII(X,3) 67 "C"
\$ASCII(X,0) –1 no character there...
\$ASCII(X,6) –1 no character there...
\$ASCII(X,–2) –1 no character there...
\$ASCII(X,1.92) 65 "A" in position 1

Assume that X=""

Reference Value Remarks
\$ASCII(X) –1 no character there...
\$ASCII(X,N) –1 no character there...

Assume that X="AB"

Reference Value Remarks
\$ASCII(X,0) –1 no character there...
\$ASCII(X,3) –1 no character there...
\$ASCII(X,–7) –1 no character there...
\$ASCII(X,1.92) 65 1.92 truncates to 1

Examples with naked references:

\$ASCII(VALUE)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=\$ASCII(^(5,6))

; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. store ^(3,4) = ^ABC(1,5,3,4)
; naked indicator is now: ^ABC(1,5,3,

\$ASCII(VALUE,POS)
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Set ^(3,4)=\$ASCII(^(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,