MSM-Workstation
Building a Non-Trivial Application
Texts to be Inserted as Code to Handle Events

The tutorial that starts with Create the First Set of Windows builds an application that illustrates the use of the various components of windows, and shows how M[UMPS] code can be specified to process the various events that may occur when an end-user runs the application.

The texts below are offered, so that the time building the application can be reduced by cutting text from the sections below and pasting the text into the various dialog-windows when "action logic" for the various events is entered.

First Window

ntrnw07.htm, Create FirstWindow

 d:'$d(^macbeth("Person")) ^demoinit
 s demosrch=0

ntrnw09.htm, Create DropDown1

 n i,x
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s x(i)=$p(^macbeth("Person",i),"|",1)
 k ^$w(%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%CurrWin,"G","DropDown1","CHOICE")=x

ntrnw09.htm, gotFocus DropDown1

 n i,n,t,x
 s n=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 q:$g(demolast)=n
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s t=$p(^macbeth("Person",i),"|",1)
 . s:t[n x(i)=t
 . q
 k ^$w(%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%CurrWin,"G","DropDown1","CHOICE")=x
 s demolast=n

ntrnw10.htm, Create DropDown1

 n i,x
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s x(i)=$p(^macbeth("Person",i),"|",1)
 k ^$w(%%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%%CurrWin,"G","DropDown1","CHOICE")=x

ntrnw10.htm, gotFocus DropDown1

 n i,n,t,x
 s n=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 q:$g(demolast)=n
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s t=$p(^macbeth("Person",i),"|",1)
 . s:t[n x(i)=t
 . q
 k ^$w(%%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%%CurrWin,"G","DropDown1","CHOICE")=x
 s demolast=n

ntrnw11.htm, Message Box

 d I^%msgbox("Creating Text Box")

ntrnw11.htm, Message Box with Title

 d I^%msgbox("This goes in the box","This on top")

ntrnw12.htm, gotFocus DropDown1

 n i,n,t,x
 s n=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 q:$g(demolast)=n
 s ^$w(%%CurrWin,"PTYPE")="M,WAIT"
 Hang 10
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s t=$p(^macbeth("Person",i),"|",1)
 . s:t[n x(i)=t
 . q
 k ^$w(%%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%%CurrWin,"G","DropDown1","CHOICE")=x
 s demolast=n
 s ^$w(%%CurrWin,"PTYPE")="Z,POINTER"

ntrnw16.htm, select DropDown1

 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 %%DoWin(SecondWindow)

ntrnw19.htm, select DropDown1

 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s demosrch(demosrch)=demonum
 %%OpenWin(SecondWindow[demosrch])

ntrnw20.htm, select DropDown1

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 s demosrch(demosrch)=demonum
 %%OpenWin(SecondWindow[demosrch],,x)

ntrnw21.htm, select DropDown1

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s ^$w(%%CurrWin,"G","Button1","ACTIVE")=1
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 s demosrch(demosrch)=demonum
 %%OpenWin(SecondWindow[demosrch],,x)

ntrnw21.htm, gotFocus DropDown1

 n i,n,t,x
 s n=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 q:$g(demolast)=n
 s ^$w(%%CurrWin,"PTYPE")="M,WAIT"
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . s t=$p(^macbeth("Person",i),"|",1)
 . s:t[n x(i)=t
 . q
 k ^$w(%%CurrWin,"G","DropDown1","CHOICE")
 k ^$w(%%CurrWin,"G","DropDown1","VALUE")
 m ^$w(%%CurrWin,"G","DropDown1","CHOICE")=x
 s ^$w(%%CurrWin,"G","Button1","ACTIVE")=0
 s demolast=n
 s ^$w(%%CurrWin,"PTYPE")="Z,POINTER"

ntrnw23.htm, Push Button1

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 s demosrch(demosrch)=demonum
 %%OpenWin(ThirdWindow[demosrch],,x)

ntrnw24.htm, Push Button4

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(FourthWindow[demosrch],,x)

ntrnw24.htm, Push Button2

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(FifthWindow[demosrch],,x)

ntrnw24.htm, Push Button3

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(SithWindow[demosrch],,x)

ntrnw24.htm, Push Button5

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(SeventhWindow[demosrch],,x)

ntrnw24.htm, Push Button6

 n x
 s demonum=^$w(%%CurrWin,"G","DropDown1","VALUE")
 s demosrch=demosrch+1
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(EighthWindow[demosrch],,x)

ntrnw24.htm, Push Button7

 n x
 s demonum=^$o(^macbeth("Person",""),-1)+1
 s ^macbeth("Person",demonum)="New Person"
 s x=demosrch#10+2_0,x="POS="_x_","_x
 %%OpenWin(FifthWindow[demosrch],,x)

Second Window

ntrnw15.htm, Create Label1

 n x
 s x=$p(^macbeth("Person",demonum),"|",1)
 s ^$w(%%CurrWin,"G","Label1","TITLE")=x

ntrnw15.htm, Create Label2

 n x
 s x=$p(^macbeth("Person",demonum),"|",2)
 s ^$w(%%CurrWin,"G","Label2","TITLE")=x

ntrnw15.htm, Create Label3

 n x
 s x=$g(^macbeth("ICO",demonum))
 s x=$s(x="":"No picture available",1:x)
 s ^$w(%%CurrWin,"G","Label3","TITLE")=x

ntrnw15.htm, Create Picture1

 n x
 s x=$g(^macbeth("ICO",demonum))
 i x="" s ^$w(%%CurrWin,"G","Picture1","VISIBLE")=0 q
 %%Set(Picture1.Picture,"F,"_x)

ntrnw18.htm, CommonCode SecondWindow

labelsiz(gadget,font,size) n lp,w,ws
; lp = label position
; w  = window information
; ws = window size
 s ws=^$w(%%CurrWin,"SIZE")
 s lp=^$w(%%CurrWin,"G",gadget,"POS")
 s w("SIZE")=$p(ws,",",1)-(2*$p(lp,",",1))
 s w("SIZE")=w("SIZE")_","_size_","_$p(ws,",",3)
 s w("TFFACE")=font
 s w("TFSIZE")=size
 m ^$w(%%CurrWin,"G",gadget)=w
 q

ntrnw18.htm, Create Label1

 n x
 d labelsiz("Label1","Arial",18)
 s x=$p(^macbeth("Person",demonum),"|",1)
 s ^$w(%%CurrWin,"G","Label1","TITLE")=x

ntrnw18.htm, Create Label2

 n x
 d labelsiz("Label2","Arial",14)
 s x=$p(^macbeth("Person",demonum),"|",2)
 s ^$w(%%CurrWin,"G","Label2","TITLE")=x

ntrnw18.htm, Create Label3

 n x
 d labelsiz("Label3","Courier",9)
 s x=$g(^macbeth("ICO",demonum))
 s x=$s(x="":"No picture available",1:x)
 s ^$w(%%CurrWin,"G","Label3","TITLE")=x

ntrnw18.htm, resize SecondWindow

 d labelsiz("Label1","Arial",18)
 d labelsiz("Label2","Arial",14)
 d labelsiz("Label3","Courier",9)

ntrnw18.htm, maximize SecondWindow

 d labelsiz("Label1","Arial",18)
 d labelsiz("Label2","Arial",14)
 d labelsiz("Label3","Courier",9)

ntrnw18.htm, restore SecondWindow

 d labelsiz("Label1","Arial",18)
 d labelsiz("Label2","Arial",14)
 d labelsiz("Label3","Courier",9)

ntrnw20.htm, Create SecondWindow

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t

Third Window

ntrnw22.htm, Create ThirdWindow

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t

ntrnw22.htm, Create Document1

 n w
 s w("SIZE")=^$w(%%CurrWin,"SIZE")
 s w("POS")="0,0,ZDLG"
 s w("TITLE")=""
 s w("VALUE")=$$getall^demodisp(demonum)
 m ^$w(%%CurrWin,"G","Document1")=w

ntrnw22.htm, resize ThirdWindow

 n x
 s x=^$w(%%CurrWin,"SIZE")
 s ^$w(%%CurrWin,"G","Document1","SIZE")=x

ntrnw22.htm, maximize ThirdWindow

 n x
 s x=^$w(%%CurrWin,"SIZE")
 s ^$w(%%CurrWin,"G","Document1","SIZE")=x

ntrnw22.htm, restore ThirdWindow

 n x
 s x=^$w(%%CurrWin,"SIZE")
 s ^$w(%%CurrWin,"G","Document1","SIZE")=x

Fourth Window

ntrnw24.htm, Create FourthWindow

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t

ntrnw24.htm, Create TextBox1

 n x
 s x=$p($g(^macbeth("EMail",demonum)),"|",1)
 s ^$w(%%CurrWin,"G","TextBox1","VALUE")=x

ntrnw24.htm, Create TextBox2

 n x
 s x=$p($g(^macbeth("EMail",demonum)),"|",2)
 s ^$w(%%CurrWin,"G","TextBox2","VALUE")=xt

ntrnw24.htm, Create TextBox3

n x
s x=$p($g(^macbeth("EMail",demonum)),"|",3)
s ^$w(%%CurrWin,"G","TextBox3","VALUE")=x

ntrnw24.htm, Push Button1

 n e1,e2,e3,x
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","TextBox3","VALUE"))
 s ^macbeth("EMail",demonum)=e1_"|"_e2_"|"_e3
 q

ntrnw24.htm, Create Label1

 s ^$w(%%CurrWin,"G","Label1","TITLE")=demonum

ntrnw24.htm, Push Button1

 n e1,e2,e3,x
 s demonum=^$w(%%CurrWin,"G","Label1","TITLE")
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","TextBox3","VALUE"))
 s ^macbeth("EMail",demonum)=e1_"|"_e2_"|"_e3
 q

Fifth Window

Create window

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t
 s ^$w(%%CurrWin,"YUNIQ")=demonum

Create TextBox1

 n x
 s x=^macbeth("Person",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",1)

Create TextBox2

 n x
 s x=^macbeth("Person",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",2)

Create CheckBox1

 n x
 s x=^macbeth("Person",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",3)

Push Button1

 n e1,e2,e3,x
 s demonum=^$w(%%CurrWin,"YUNIQ")
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","CheckBox1","VALUE"))
 s ^macbeth("Person",demonum)=e1_"|"_e2_"|"_e3
 q

Sixth Window

Create window

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t
 s ^$w(%%CurrWin,"YUNIQ")=demonum

Create TextBox1

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",1)

Create TextBox2

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",2)

Create TextBox3

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",3)

Create TextBox4

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",4)

Create TextBox5

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",5)

Create TextBox6

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",6)

Create TextBox7

 n x
 s x=^macbeth("Address",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",7)

Push Button1

 n e1,e2,e3,e4,e5,e6,e7,x
 s demonum=^$w(%%CurrWin,"YUNIQ")
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","TextBox3","VALUE"))
 s e4=$g(^$w(%%CurrWin,"G","TextBox4","VALUE"))
 s e5=$g(^$w(%%CurrWin,"G","TextBox5","VALUE"))
 s e6=$g(^$w(%%CurrWin,"G","TextBox6","VALUE"))
 s e7=$g(^$w(%%CurrWin,"G","TextBox7","VALUE"))
 s ^macbeth("Address",demonum)=e1_"|"_e2_"|"_e3_"|"_e4_"|"_e5_"|"_e6_"|"_e7
 q

Seventh Window

Create window

 n t,x
 s demonum=1
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t
 s ^$w(%%CurrWin,"YUNIQ")=demonum

Create TextBox1

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",1)

Create TextBox2

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",2)

Create TextBox3

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",3)

Create TextBox4

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",4)

Create TextBox5

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",5)

Create TextBox6

 n x
 s x=$g(^macbeth("Phone",demonum))
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=$p(x,"|",6)

Create DropDown1

 n i,x
 s i="" f  s i=$o(^macbeth("Person",i)) q:i=""  d
 . q:i=demonum
 . s x(i)=$p(^macbeth("Person",i),"|",1)
 . q
 k ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")
 k ^$w(%%CurrWin,"G",%%CurrCtl,"CHOICE")
 m ^$w(%%CurrWin,"G",%%CurrCtl,"CHOICE")=x
 s x=$p($g(^macbeth("Phone",demonum)),"|",8)
 s:x'="" ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=x
 q

Push Button1

 n e1,e2,e3,e4,e5,e6,e7,e8,x
 s demonum=^$w(%%CurrWin,"YUNIQ")
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","TextBox3","VALUE"))
 s e4=$g(^$w(%%CurrWin,"G","TextBox4","VALUE"))
 s e5=$g(^$w(%%CurrWin,"G","TextBox5","VALUE"))
 s e6=$g(^$w(%%CurrWin,"G","TextBox6","VALUE"))
 s e8=$g(^$w(%%CurrWin,"G","DropDown1","VALUE"))
 s e7="" s:e8 e7=$p($g(^macbeth("Phone",e8)),"|",2)
 s ^macbeth("Phone",demonum)=e1_"|"_e2_"|"_e3_"|"_e4_"|"_e5_"|"_e6_"|"_e7_"|"_e8
 q

Eighth Window

Create window

 n t,x
 s x=^macbeth("Person",demonum)
 s t=$p(x,"|",1),x=$p(x,"|",2)
 s:x'="" t=t_", "_x
 s ^$w(%%CurrWin,"TITLE")=t
 s ^$w(%%CurrWin,"YUNIQ")=demonum

Create TextBox1

 n x
 s x=^macbeth("ICO",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=x

Create TextBox2

 n x
 s x=^macbeth("GIF",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=x

Create TextBox3

 n x
 s x=^macbeth("BMP",demonum)
 s ^$w(%%CurrWin,"G",%%CurrCtl,"VALUE")=x

Push Button1

 n e1,e2,e3,x
 s demonum=^$w(%%CurrWin,"YUNIQ")
 s e1=$g(^$w(%%CurrWin,"G","TextBox1","VALUE"))
 s e2=$g(^$w(%%CurrWin,"G","TextBox2","VALUE"))
 s e3=$g(^$w(%%CurrWin,"G","CheckBox1","VALUE"))
 f x="ICO","GIF","BMP" k ^macbeth(x,demonum)
 s:e1'="" ^macbeth("ICO",demonum)=e1
 s:e2'="" ^macbeth("GIF",demonum)=e2
 s:e3'="" ^macbeth("BMP",demonum)=e3
 q

Application

ntrgs4.htm, Enter Module macbeth

 %%DoWin(FirstWindow)

ntrgs4.htm, Enter Module macbeth

 n in,out,x
 s in("DBNAME")="c:\...your...directory...\macbeth.m"
 s in("LOCAL_ACCESS")="M"
 d LMOUNT^%msv(.in,.out)
 s x=out("VGNAME")
 k in,out
 s x=$tr($zu(0),",","^")_"^"_x_"^"_x_"^"_x"_^"_x
 s x=x_"^5^^STRING^macbeth^8"
 s in("TRANSLATE")=x
 d ENTRAN^%msv(.in)
 %%DoWin(FirstWindow)