Você está na página 1de 8

MUMPS Quick Reference

Editor Commands
1. A RNG{STR1}
- ALL
2. C LN1,INR,RNG,[PMG] - COPY
3. D RNG
- DELETE
4. LN1(tab)TAG(tab)CODE - DIRECT MODE
5. F
- FILE
6. FQ
- &QUIT
7. FR
- &RECOMPILE
8. I LN1 INCR
- INSERT
9. J LN1 LN2
- JOIN
10. L
- LOAD
11. LR
- &PROMPT
12. N LN1,INCR,RNG
- RELOCATE
13. P RNG
- PRINT
14. Q
- QUIT
15. R RNG {STR1} {STR2} - REPLACE
16. RC
- RTN COMPARE
17. S RNG{STR1}
- SEARCH
18. X STR1
- XECUTE
D ^%Z
PGM
#
*
RTN

- invokes the editor


- Program name to be edited ^ for the last PGM edited
- The editor prompt for commands.
- end of file
- routine pneumonic

Procedure to use mumps


Logon procedure:
> C SMP
>M
> D ^%ZPA
> ESI
Help:
> D ^VESCMD
> AAA
> AAA
^D00
^%ZG
^LTN
^ZLP
^ZNT

-login screen
-mumps prompt
-uci prompt
-mumps
-ESI Security prompt
-Initials
-PWD

Transaction processor
global display
transaction file
outputs a formatted output to a terminal or o/p device
Allows review of all changes to an edited pgm

MUMPS function references


1. $A $ASCII
2. $C $CHAR
3. $D $DATA
4. $E $EXTRACT
5. $F $FIND
6. $FN $FNUMBER
7. $G $GET
8. $J $JUSTIFY
9. $L $LENGTH
10. $N $NEXT
11. $O $ORDER
12. $P $PIECE
13. $Q $QUERY
14. $R $RANDOM
15. $S $SELECT
16. $T $TEXT
17. $TR $TRANSLATE
18. $V $VIEW
19. $Z $Z
20. $X $X
21. $Y $Y
22. $H DATE-TIME
23. _
_
24. ?
?
25. $s 26. $IO $IO
27. $$ $$
28. ^DAT

decimal ASCII code


integer to character
returns a integer if data available
sub string of a input string
finds position of sub string within a string
formats numeric data
returns value of a variable if defined
right justify data
length of a string
next available subscript at same level
($N-returns a ve number. This = null string)
returns a sub string of a input string
returns the next available array node
returns a random number
returns the first value from a list of values
returns the text in the routine
replace a sub string by another sub string
machine dependent information
value implementation specific.
horizontal cursor position
vertical cursor position
returns the date and time
Concatenate operator
Pattern match
select value
current device
Extrinsic function- functions created by programmer
readable dates

MUMPS Commands
B
C
D
E
F
G
H
I
J
K
L
N
O
Q
R
S
U
V
W
X
Z

BREAK
CLOSE
DO
ELSE
FOR
GOTO
HALT
IF
JOB
KILL
LOCK
NEW
Open
QUIT
READ
SET
USE
VIEW
WRITE
XECUTE
Z

suspend program execution


relinquish ownership of an i/o device
call a subroutine
else of course value of test
repeatedly execute a set of commands
goto
suspend the execution for a specified period of time
if
creates a new MUMPS process( initiate a background job)
removes a variable
places a pseudo-lock on the variable
Allows for a variable to be saved and reused within the scope of the subroutine
Obtain exclusive ownership of a IO device
Terminate the execution of a subroutine
Accepts data from a Input device and stores it
Assigns the result of an expression to a variable
Specifies an i/o device as the current device
Examine /modify machine dependant information
Outputs data to the current device
Executes a MUMPS string
Performs some action specified by the implementer

Arithmetic Operators
+
/
*
**
\
#

Addition
Subtraction
Division
Multiplication
Exponentiation
Integer Division
Modulo remainder

Other operators
<
>
=
{
}
?
&
!

less than
greater than
equals
contains
follows
patter matches
And
Or
Not

OVERVIEW
Data types: one universal datatype, interpreted/converted to string, integer, or
floating-point number as context requires. Like Visual BASIC "variant" type.
Booleans: In IF statements and other conditionals, any nonzero value is treated as
True. a<b yields 1 if a is less than b, 0 otherwise.
Declarations: none. Everything dynamically created on first reference.
Lines: important syntactic entities. Multiple statements per line are idiomatic.
Scope of IF and FOR is "remainder of current line."
Case sensitivity: Commands and intrinsic functions are case-insensitive. Variable
names and labels are case-sensitive. No specified meaning for upper vs. lowercase and no widely accepted conventions. Percent sign (%) is legal as first
character of variables and labels.
Postconditionals: SET:N<10 A="FOO" sets A to "FOO" if N is less than 10; DO:N>100
PRINTERR performs PRINTERR if N is greater than 100. Provides a conditional whose
scope is less than the full line.
Arrays: created dynamically, stored sparsely as B-trees, any number of subscripts,
subscripts can be strings or integers. Always automatically stored in sorted order.
$ORDER and $QUERY functions allow traversal.
for I=10000:1:12345 set SQTABLE(I)=I*I
set ADDRESS("Smith","Daniel")="dpbsmith@world.std.com"

Local arrays: names not beginning with caret; stored in process space; private to
your process; expire when process terminates; available storage depends on
partition size but is typically small (32K)
Global arrays: ^ABC, ^DEF. Stored on disk, available to all processes, persist
when process terminates. Very large globals (hundreds of megabytes) are practical
and efficient. This is M's main "database" mechanism. Used instead of files for
internal, machine-readable recordkeeping.
Indirection: in many contexts, @VBL can be used and effectively substitutes the
contents of VBL into the statement. SET XYZ="ABC" SET @XYZ=123 sets the variable
ABC to 123. SET SUBROU="REPORT" DO @SUBROU performs the subroutine named
REPORT. Operational equivalent of "pointers" in other languages.
Piece function: Treats variables as broken into pieces by a separator.

means the "third caret-separated piece of STRINGVAR." Can


appear as an assignment target. After
$PIECE(STRINGVAR,"^",3)

SET X="dpbsmith@world.std.com"
$PIECE("world.std.com",".",2) yields "std".
SET $P(X,"@",1)="office" causes X to become "office@world.std.com" .

Order function:
Set STUFF(6)="xyz",STUFF(10)=26,STUFF(15)=""
$Order(STUFF("")) yields 6, $Order(STUFF(6)) yields 10, $Order(STUFF(8))
$Order(STUFF(10)) yields 15, $Order(STUFF(15)) yields "".

yields 10,

Set I="" For Set I=$O(STUFF(I)) Quit:I="" Write !,I,?10,STUFF(I)

The argumentless For iterates until stopped by the Quit. Prints a table of I and
STUFF(I) where I is successively 6, 10, and 15.

Commands: may be abbreviated to one letter, case-insensitive.


DO XYZ
DO PQR(arg1,arg2,arg3)
ELSE stmnt1 stmnt2 stmnt3
FOR stmnt1 stmnt2 stmnt3
FOR i=1:1:100 stmnt1 ...
GOTO
IF cnd stmnt1 stmnt2 stmnt3
KILL vbl
NEW vbl1,vbl2,vbl3
QUIT
QUIT value
READ "Prompt:",X
SET a=22,name="Dan",(c,d)=0
USE 23
WRITE !,"x=",x
XECUTE("set a=5 do xyz")

call subroutine at label XYZ


call with parameter passing
opposite of last IF
repeat until a QUIT breaks you out
iteration, i=1, 2, 3, ... 100
yes, there is one
conditionally execute rest of line
return vbl to "undefined" state
stack old values, create fresh "undefined" state. Pop
on QUIT.
return from subroutine
return from extrinsic function
on current I/O stream, first write "Prompt:", then
read line into variable X
variable assignment
switch I/O stream to device 23
output to current I/O stream. ! means new line
execute arbitrary data as M code

Operators: No precedence, executed left to right, parenthesize as desired.


2+3*10 yields 50.
+-*/
\
#
_
&!'<>
[
]
?

sum, difference, product, quotient


integer division, 1234\10 yields 123
modulo
concatenation, "nice"_2_"use" --> "nice2use"
and, or, not, less, greater, equal
string contains. "ABCD"["BC" --> 1
string lexically follows. "Z"]"A" --> 1
pattern match operator

Intrinsic (built-in) functions: Important structural components of the language


(not commonly found in other languages):
$DATA(V)
$ORDER, $QUERY
$ORDER(A("abc"))

tests if a variable V is defined (has data) or not


traverse arrays in sorted order
value V is the next subscript, following "abc",

$PIECE
$SELECT(c1:v1,c2:v2,1:v3)
$TEXT(FOO+3)

according to the M collating sequence, such that


a(V) is defined
see above
if c1 is true yields v1, else if c2 is true yields v2,
otherwise yields v3
returns text of source code at line FOO+3

Convenience functions similar to library functions in other languages:


$ASCII, $CHAR
$EXTRACT(STRING,5,10)
$FIND(string,find,from)
$FNUMBER
$LENGTH(string)
$RANDOM(100)
$TRANSLATE("abcd","ab","AB")

text-to-ASCII-code and inverse


characters 5 through 10 of STRING;
may be assignment target
substring search
floating point formatting
just what you think
random # in range 0 to 99 inclusive
character substitution; yields "ABcd"

list a global directory:


Function
Utility Menu

MSM
%UTL

DSM
%UTL

MVX/MSQL
UTIL

DTM
zzu

Routine Directory %RD/%ROU %RD/%RDX %RD/%RDISP %rd


Routine Print

%RP

Routine Change

%RCHANGE %RCE

Routine COmpare %RCMP

%RS/%ZTPP %RO/ZP
%RCMP

%rsave

%RCHANGE %rsearch
%RCMP

%rloadcompare

Global Directory %GD/%GLO %GD

%GD/%GDISP %gd

Global List

%GL

%G

%G

%g

Global Edit

%GEDIT

%GEDT

%GED

%gedit

Global Change

%GCHANGE %ZGE

%GCHANGE %gedit

Global Transfer

%GCOPY

%GOQ/%GIQ

%GC

Você também pode gostar