Mumps Class 4

From VistApedia
Revision as of 13:48, 2 April 2011 by Shabiel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Using username "sw-dev".
sw-dev@172.16.16.108's password:
Linux swdev 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

213 packages can be updated.
174 updates are security updates.

Last login: Sun Jan 16 09:28:21 2011 from hebalafi-laptop.local
sw-dev@swdev:/var/worldvista/sw/dev$ gtm

sw-dev> D ^%RD

Routine directory
Routine: KJO*
KJO8CIRC  KJOXCIRM
Total of 2 routines.

Routine:

sw-dev> ZED "KJOXCIRM"

sw-dev> ZP ^KJOXCIRM
CIRM
 ;
 N X,RA,P
 S X=0,R=0,P=3.14
 ;
MENU
 W !,!,!
 W "SELECT AN OPTION:-",!
 W "1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)",!
 W "2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE",!
 W "3.QUIT",!
 R X,!
 IF X>3 W "ENTER A VALIED OPTION NUMBER",! GOTO MENU
 IF X=3 Q
 IF X=1 W !,"THE CIRM FOR THE CIRCLE IS:- ",2*12.5*P,! GOTO MENU
 IF X=2 W "PLEASE ENTER THE CIRLCE RADUIS:- " R RA
 IF RA<0 S RA=0
 W !,"THE CIRM FOR THE CIRCLE IS:- ",2*RA*P,! GOTO MENU


sw-dev> D ^KJOXCIRM



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
-1
%GTM-E-UNDEF, Undefined local variable: RA
                At M source location MENU+11^KJOXCIRM

sw-dev> ZG

sw-dev> D ^KJOXCIRM



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
0
%GTM-E-UNDEF, Undefined local variable: RA
                At M source location MENU+11^KJOXCIRM

sw-dev> ZG

sw-dev> D ^KJOXCIRM



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
4
ENTER A VALIED OPTION NUMBER



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
1

THE CIRM FOR THE CIRCLE IS:- 78.5



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
2
PLEASE ENTER THE CIRLCE RADUIS:- 66
THE CIRM FOR THE CIRCLE IS:- 414.48



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
2
PLEASE ENTER THE CIRLCE RADUIS:- -8
THE CIRM FOR THE CIRCLE IS:- 0



SELECT AN OPTION:-
1.CALCULATE A CIRCUMFERENCE FOR A CIRCLE WITH A RADUIS OF (12.5)
2.ENTER A RADUIS TO CALCULATE THE CIRCUMFERENCE FOR THE CIRCLE
3.QUIT
3

sw-dev> ZED

sw-dev> D ^%RD

Routine directory
Routine: KJO*
KJO8CIRC  KJOXCIRM
Total of 2 routines.

Routine:

sw-dev>

sw-dev> ZP ^KJO8CIRC
KJO8CIRC
 ;
 ;
 S PI=(22/7)
 W !,"Circumference of a circle of radius (12.5) is: "
 S Circim=2*PI*12.5
 W Circim,!
 ;
 W !,"Enter a new radius for another circle: "
 R RAD
 S Circim=2*PI*RAD
 W !,"Circumference of a circle of radius ("_RAD_") is: "
 I Circim<0 W "0",!
 E  W Circim,!
 W "See you next time, bye"
 ;

sw-dev> ZED "KJO8CIRC"

sw-dev> ZED "KJOXCIRM"

sw-dev> ZED "KJO8CIRC"

sw-dev> D ^KJO8CIRC

Circumference of a circle of radius (12.5) is: 78.5714285714285712

Enter a new radius for another circle: 33
Circumference of a circle of radius (33) is: 207.428571428571428
See you next time, bye
sw-dev> D ^KJO8CIRC

Circumference of a circle of radius (12.5) is: 78.5714285714285712

Enter a new radius for another circle: -12
Circumference of a circle of radius (-12) is: 0
See you next time, bye
sw-dev> h
sw-dev@swdev:/var/worldvista/sw/dev$ gtm

sw-dev> ; Strings, and String Operators

sw-dev> ; To store a string, use quotes

sw-dev> ; otherwise Mumps will try to interpret it as a number,

sw-dev> ; then store the number as a string.

sw-dev> W "03"
03
sw-dev> W 03
3
sw-dev> ; String functions: $ASCII, $CHAR, $TRANSLATE, $LENGTH, $PIECE

sw-dev> ; $EXTRACT, $FIND

sw-dev> WRITE $ASCII(
%GTM-E-EXPR, Expression expected but not found
        WRITE $ASCII(
                     ^-----

sw-dev> WRITE $ASCII("A")
65
sw-dev> WRITE $ASCII("a")
97
sw-dev> WRITE $ASCII("ا")
199
sw-dev> S X="A"

sw-dev> WRITE $ASCII(X)
65
sw-dev> S X="Apple"

sw-dev> WRITE $ASCII(X)
65
sw-dev> ; $ASCII TAKES first character by default

sw-dev> ; there is a 2 argument $ASCII

sw-dev> WRITE $ASCII(X,2)
112
sw-dev> WRITE $ASCII(X,3)
112
sw-dev> ; 2 argument $ASCII gives you the character at a specific position

sw-dev> ; Opposite of $ASCII is $Character

sw-dev> W $CHARACTER(65)
%GTM-E-INVFCN, Invalid function name

sw-dev> W $CHAR(65)
A
sw-dev> W $CHAR(27)

w-dev>

sw-dev> W $CHAR(27),"c"

sw-dev> W $CHAR(27),"[31m"

sw-dev> W $CHAR(27),"c"

sw-dev> WRITE $CHAR(10)


sw-dev> WRITE $CHAR(10,13)


sw-dev> ; 10 is new line

sw-dev> ; 13 is carriage return

sw-dev> ; Linux line endings are just $C(10)

sw-dev> ; Windows line endings are $C(13,10)

sw-dev> ; $Character is abbreviated as $C

sw-dev> ; $C can take any number of arguments

sw-dev> WRITE $CHAR(65,66,67,68,69,70)
ABCDEF
sw-dev> ; $TRANSLATE

sw-dev> ; $Translate has two uses: change characters or remove characters

sw-dev> ; Most common use of $Translate is to change case.

sw-dev> S X="Apple"

sw-dev> W $TRANSLATE("Apple","p","P")
APPle
sw-dev> W $TRANSLATE("Apple","abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTU
VWXYZ")
APPLE
sw-dev> ; This function is in XLFSTR in VISTA.

sw-dev> ZP UP^XLFSTR:UP+3
UP(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 ;
LOW(X) Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
 ;

sw-dev> ; To use this function:

sw-dev> WRITE $$UP^XLFSTR("Hello")
HELLO
sw-dev> WRITE $$LOW^XLFSTR("HELLO")
hello
sw-dev> WRITE $$LOW^XLFSTR("HEL3243234LO")
hel3243234lo
sw-dev> ; Other use is to remove characters

sw-dev> ; E.g. remove spaces

sw-dev> WRITE $TR("Mary had a little lamb."," ","")
Maryhadalittlelamb.
sw-dev> ; $Translate has a 2 argument form; the 3rd argument is assumed to be an
 empty string.

sw-dev> ; $Translate has a 2 argument form; the 3rd argument is assumed to be an
sw-dev> WRITE $TR("Mary had a little lamb."," ")
Maryhadalittlelamb.
sw-dev> ; 2 argument form of $Translate removes everything in the second argumen
t from the string.

sw-dev> WRITE $TR("hELO2982374O","1234567890")
hELOO
sw-dev> ; $Length / $L

sw-dev> WRITE $L("apple")
5
sw-dev> ; $Length as a 2 argument form.

sw-dev> ; This counts the pieces if the second argument is considered to be a de
limiter

sw-dev> WRITE $L("apple,pear",",")
2
sw-dev> ; This is typically used with $Piece

sw-dev> ; $Piece / $P

sw-dev> ; Given a delimiter, what's the piece of of the string at a specific pos
ition?

sw-dev> zwrite ^DPT(1:3,0)
^DPT(1,0)="ييي,مريض ثلاثة^F^2450124^^2^^NOE^^000003322^^LAS VEGAS^32^^^68^306051
          1^^^^1"
^DPT(2,0)="ييي,مريض اربعة-عشر^M^2571225^^15^^SAILOR^29^123456789^Test patient on
          ly, please use to test, train^BOSTON^25^^^112^3100530^^^^1"
^DPT(3,0)="ييي,مريض عشرة^M^3090115^^15^^UNEMPLOYED^^769011509P^^MIAMI^12^^^112^3
          100223^^^^1"

sw-dev> ; Vista's delimiter is usually the "^"

sw-dev> S X="ONE^TWO^THREE^FOUR^FIVE"

sw-dev> WRITE $PIECE(X,"^",1)
ONE
sw-dev> WRITE $PIECE(X,"^",2)
TWO
sw-dev> WRITE $PIECE(X,"^",4)
FOUR
sw-dev> WRITE $PIECE(X,"^",5)
FIVE
sw-dev> WRITE $PIECE(X,"^",6)

sw-dev> ; Empty string

sw-dev> WRITE $PIECE(X,"^",6)=""
1
sw-dev> ; Mumps confirms that it is an empty string

sw-dev> ; $Piece has 2 argument and 4 argument forms, in addition to the most co
mmon 3 argument form.

sw-dev> WRITE $PIECE(X,"^")
ONE
sw-dev> ; 2 argument gives you the first piece.

sw-dev> ; 4 argument

sw-dev> WRITE $PIECE(X,"^",1,2)
ONE^TWO
sw-dev> WRITE $PIECE(X,"^",1,3)
ONE^TWO^THREE
sw-dev> WRITE $PIECE(X,"^",1,4)
ONE^TWO^THREE^FOUR
sw-dev> WRITE $PIECE(X,"^",1,5)
ONE^TWO^THREE^FOUR^FIVE
sw-dev> WRITE $PIECE(X,"^",1,6)
ONE^TWO^THREE^FOUR^FIVE
sw-dev> WRITE $PIECE(X,"^",1,6)=$PIECE(X,"^",1,5)
1
sw-dev> ; 4 argument $Piece gives you a portion of the delimited string, as you
desire.

sw-dev> W ^DPT(1,0)
ييي,مريض ثلاثة^F^2450124^^2^^NOE^^000003322^^LAS VEGAS^32^^^68^3060511^^^^1
sw-dev> W $P(^DPT(1,0),"^",2)
F
sw-dev> W $P(^DPT(1,0),"^",3)
2450124
sw-dev> S X=$P(^DPT(1,0),"^",3)

sw-dev> W X
2450124
sw-dev> W $$FMTE^XLFDT(X)
Jan 24, 1945
sw-dev> ; $Extract

sw-dev> ; $E

sw-dev> ; Gets a piece of a string by character

sw-dev> S X="HELLO MARY"

sw-dev> W $EXTRACT(X,1,3)
HEL
sw-dev> W $EXTRACT(X,1,4)
HELL
sw-dev> W $EXTRACT(X,0,4)
HELL
sw-dev> W $EXTRACT(X,0,4)=$EXTRACT(X,1,4)
1
sw-dev> ; $EXTRACT most commonly is a 3 argument form

sw-dev> ; 1st argument: String

sw-dev> ; 2nd : Staring position

sw-dev> ; 3rd : Ending position

sw-dev> ; Also has 1 and 2 argument forms

sw-dev> W $E(X)
H
sw-dev> ; 1 arg form gets you the first character

sw-dev> W $E(X,1)
H
sw-dev> W $E(X,2)
E
sw-dev> W $E(X,3)
L
sw-dev> W $E(X,4)
L
sw-dev> W $E(X,5)
O
sw-dev> ; 2 argument form gets the specific character

sw-dev> W $E(X,-1)

sw-dev> W $E(X,-2)

sw-dev> W $E(X,-3)

sw-dev> W $E(X,-3)=""
1
sw-dev> ; $FIND / $F

sw-dev> ; compare with [ "contains"

sw-dev> W "ABCD"["C"
1
sw-dev> W $FIND("ABCD","C")
4
sw-dev> ; Returns to you the position AFTER the found string

sw-dev> ; -1 to get the actual position

sw-dev> W $FIND("ABCD","C")-1
3
sw-dev> W $FIND("Hello Mary Mary Mary","Mary")
11
sw-dev> ; Oooops... it gets the character AFTER the string

sw-dev> ; to get the actual position

sw-dev> W $FIND("Hello Mary Mary Mary","Mary")-$LENGTH("Mary")
7
sw-dev> ; 3 arg form of $FIND makes $Find start searching at a specific position

sw-dev> W $FIND("Hello Mary Mary Mary","Mary",8)
16
sw-dev> W $FIND("Hello Mary Mary Mary","Mary",7)
11
sw-dev> W $FIND("Hello Mary Mary Mary","Mary",8)-$Length("Mary")
12
sw-dev> W $EXTRACT("Hello Mary Mary Mary",12)
M
sw-dev>