Mumps Class 2

From VistApedia
Revision as of 13:42, 2 April 2011 by Shabiel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Using username "worldvistaEHR".
Authenticating with public key "rsa-key-20101206"
Linux cassandra 2.6.26-1-686 #1 SMP Fri Mar 13 18:08:45 UTC 2009 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jan  6 05:22:01 2011 from 192.168.56.1
worldvistaEHR@cassandra:~$ mumps -dir

GTM>zed "XUS"

GTM>; All storage of variables are in strings

GTM>; Using operators and functions:

GTM>; Language interprets strings as:

GTM>; 1. Number

GTM>; 2. Boolean

GTM>; 3. String

GTM>SET X=3 SET Y=4 SET Z=5

GTM>WRITE X SET A=5
3
GTM>WRITE A
5
GTM>SET X=3 SET Y=4 SET Z=5

GTM>SET X=3,Y=4,Z=5

GTM>; , means repeat command

GTM>IF A,B,C
%GTM-E-UNDEF, Undefined local variable: B

GTM>IF X,Y,Z

GTM>; equivalent to

GTM>IF X IF Y IF Z

GTM>; All of Mumps is command argument command argument, except:

GTM>; FOR, IF, ELSE

GTM>; FOR, IF, ELSE scope is everything following them

GTM>; or a procedure indicated by a DO.

GTM>SET X=3 WRITE Y
4
GTM>SET P=0 IF P WRITE Y

GTM>SET P=1 IF P WRITE Y
4
GTM>; Opposite of IF is ELSE

GTM>SET P=1 IF P WRITE Y
4
GTM>SET P=0 IF P WRITE Y

GTM>ELSE WRITE Z
%GTM-E-SPOREOL, Either a space or an end-of-line was expected but not found
        ELSE WRITE Z
             ^-----

GTM>ELSE  WRITE Z
5
GTM>; Every Mumps command requires an argument

GTM>; If command has no argument (e.g. Else) put two spaces

GTM>; For command

GTM>FOR I=1:1:100 WRITE I,! QUIT:I=56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

GTM>; FOR executes arbitraty mumps commands; and QUIT stops a FOR loop.

GTM>; Mumps Syntax: Command Argument Command Argument etc.

GTM>; Arguments: Can be Literals

GTM>WRITE "HELLO"
HELLO
GTM>; Argument: Can be an expression:

GTM>WRITE 3+5
8
GTM>WRITE (2+3)=5
1
GTM>; = is a comparison Equal; like == in C.

GTM>; Expressions can contain functions.

GTM>; Wait a minute: what are functions??

GTM>; Functions in Mumps are divided into two categories:

GTM>; Intrinsic Functions (part of the Mumps Language)

GTM>; Extrinsic Functions (defined by the Programmer)

GTM>; Example of Intrinsic Functions:

GTM>WRITE $EXTRACT("STRING",1,2)
ST
GTM>WRITE $JUSTIFY("STRING",20)
              STRING
GTM>ZED "XLFSTR"

GTM>; Example of Extrinsic Functions

GTM>WRITE $$LO^XLFSTR("STRING")
%GTM-E-LABELMISSING, Label referenced but not defined: LO

GTM>ZED

GTM>WRITE $$LOW^XLFSTR("STRING")
string
GTM>; Instrinsic Functions have only one $

GTM>; Extrinsic Functions have 2 $$

GTM>; Extrnisic Functions are always part of a routine.

GTM>WRITE $EXTRACT("STRING",1,2)
ST
GTM>write $extract("STRING",1,2)
ST
GTM>write $$low^xlfstr("STRING")
%GTM-E-ZLINKFILE, Error while zlinking "xlfstr"
%GTM-E-FILENOTFND, File xlfstr not found

GTM>; Intrinsic commands are not case sensitive

GTM>; Extrinsic, being user defined, are case sensitive.

GTM>; Expressions

GTM>; Mumps syntax, really looks like this:

GTM>; Command expression command expression command expression

GTM>zed

GTM>; Abbreviation of Commands and Instrinsic Functions

GTM>; WRITE = W

GTM>; SET = S

GTM>; $EXTRACT = $E

GTM>WRITE "HELLO"
HELLO
GTM>W "HELLO"
HELLO
GTM>WR "HELLO"
%GTM-E-INVCMD, Invalid command keyword encountered
        WR "HELLO"
        ^-----

GTM>WRITE $EXTRACT("HELLO",1,2)
HE
GTM>WRITE $E("HELLO",1,2)
HE
GTM>W $E("HELLO",1,2)
HE
GTM>; READ = R

GTM>R X
8
GTM>W X
8
GTM>; Mumps does not have reserved words in the language

GTM>; Why?

GTM>; Because it has a set syntax of command expression

GTM>; If something is in the command section, it will be interpreted as a command

GTM>; and vice versa

GTM>SET SET=1

GTM>WRITE SET
1
GTM>; Entering numbers vs entering strings

GTM>SET X=0033

GTM>WRITE X
33
GTM>SET X="0033"

GTM>WRITE X
0033
GTM>SET X=987SSS
%GTM-E-SPOREOL, Either a space or an end-of-line was expected but not found
        SET X=987SSS
                 ^-----

GTM>SET X=1/4

GTM>W X
.25
GTM>S Y=0.333

GTM>W Y
.333
GTM>SET Y="0.333"

GTM>WRITE Y
0.333
GTM>; Y is now a string

GTM>; Quick tip: To convert a string to number, use the + sign

GTM>WRITE Y
0.333
GTM>WRITE +Y
.333
GTM>; If you don't use quotes in the expression, mumps will try to interpret your input as either:

GTM>; 1. A number

GTM>; 2. A variable

GTM>; If you use quotes in the expression, mumps will interpret your input as a string.

GTM>; In either case, the end result is stored as a string in Mumps.

GTM>SET Y=0.33

GTM>SET Y=X

GTM>; X is a variable; Y is now equal to X.

GTM>; Mumps Limits

GTM>; 95 Standard:

GTM>; - Strings can be 255 characters long

GTM>; - Numbers up to 15 digits accurate

GTM>; In reality:

GTM>; Cache: Strings 32000 characters long; GT.M: 1 million +

GTM>; GT.M can take numbers more than 15 digits accurate.

GTM>; Introducing... Exponential notation

GTM>S X=3E5

GTM>W X
300000
GTM>S X=3E20

GTM>W X
300000000000000000000
GTM>S X=3E40

GTM>W X
30000000000000000000000000000000000000000
GTM>S X=3E60
%GTM-E-NUMOFLOW, Numeric overflow
        S X=3E60
           ^-----

GTM>S X=3E50
%GTM-E-NUMOFLOW, Numeric overflow
        S X=3E50
           ^-----

GTM>S X=3E45

GTM>S X=3E46

GTM>S X=3E47
%GTM-E-NUMOFLOW, Numeric overflow
        S X=3E47
           ^-----

GTM>; Subscript Length is 255 characters

GTM>S X(1,2,3,4,5,6,7,8,9,"SAM","CAT",2)=1

GTM>ZWRITE X
X=30000000000000000000000000000000000000000000000
X(1,2,3,4,5,6,7,8,9,"SAM","CAT",2)=1

GTM>WRITE $D(X)
11
GTM>WRITE $D(X(2))
0
GTM>WRITE $D(X(1))
10
GTM>WRITE $D(X(1,2))
10
GTM>WRITE $D(X(1,3))
0
GTM>; Combined subscript lenggh is 255 characters.

GTM>; Length of data in each global entry is 255 characters.

GTM>W ^SAM
5
GTM>; Variables

GTM>SET X=234

GTM>; X is a variable

GTM>; In Mumps: Variables can be up to 16 characters long.

GTM>; First letter can be %

GTM>; or [A-Za-z]

GTM>; Rest of characters can be alphabet or numbers

GTM>; What is a vaild variable name???

GTM>S 3SX=1
%GTM-E-VAREXPECTED, Variable expected in this context
        S 3SX=1
          ^-----

GTM>S DSLKJ=1

GTM>S %HEESI=1

GTM>S %3=1

GTM>S X3=1

GTM>S X%3=1
%GTM-E-EQUAL, Equal sign expected but not found
        S X%3=1
           ^-----

GTM>; % must be in the first position

GTM>S YT33WW=1

GTM>; %

GTM>; %1 to %9 can be used by programmers for temporary variables

GTM>; other % variables shouldn't be used unless you are writing utilities for VISTA.

GTM>zed "_DT"

GTM>zed "XUP"

GTM>