source: cprs/branches/tmg-cprs/m_files/TMGTREE.m

Last change on this file was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 4.5 KB
Line 
1TMGTREE ;TMG/kst/Text tree user interface ;03/25/06
2 ;;1.0;TMG-LIB;**1**;09/01/05
3
4 ;"=======================================================================
5 ;" API -- Public Functions.
6 ;"=======================================================================
7 ;"BrowseBy(CompArray,ByTag)
8 ;"ShowBy(CompArray,ByTag,aOpen,bOpen,cOpen,dSelected)
9
10 ;"=======================================================================
11 ;" Private Functions.
12 ;"=======================================================================
13
14
15
16BrowseBy(CompArray,ByTag)
17 ;"Purpose: Allow a user to interact with dynamic text tree
18 ;" that will open and close nodes.
19 ;"Input: CompArray -- array to browse. Should be in this format
20 ;" CompArray("opening tag",a,b,c,d)
21 ;" ByTag -- the name to use in for "opening tag")
22 ;"Results: returns Batch/job number, or 0 if none selected
23
24 new aOpen set aOpen=0
25 new bOpen set bOpen=0
26 new cOpen set cOpen=0
27 new dSelected set dSelected=0
28
29 new done set done=0
30
31 new input
32 new result set result=0
33
34 for do quit:(done=1)
35 . set result=$$ShowBy(.CompArray,ByTag,aOpen,bOpen,cOpen,dSelected)
36 . if result>0 set done=1 quit
37 . read !,"Enter Number to Browse ([Enter] to backup, ^ to Quit): ",input:$get(DTIME,3600),!
38 . if input="" set input=0
39 . if +input>0 do
40 . . if aOpen=0 do
41 . . . set aOpen=input,bOpen=0,cOpen=0
42 . . else if bOpen=0 do
43 . . . set bOpen=input,cOpen=0
44 . . else if cOpen=0 set cOpen=input
45 . . else set dSelected=input
46 . else if input=0 do
47 . . if cOpen'=0 set cOpen=0,dSelected=0 quit
48 . . if bOpen'=0 set bOpen=0 quit
49 . . if aOpen'=0 set aOpen=0 quit
50 . . if aOpen=0 set input="^"
51 . if input="^" set done=1
52
53 quit result
54
55
56ShowBy(CompArray,ByTag,aOpen,bOpen,cOpen,dSelected)
57 ;"Purpose: Draw current state of text tree
58 ;"Input: CompArray -- array to browse. Should be in this format
59 ;" CompArray("opening tag",a,b,c,d)
60 ;" ByTag -- the name to use in for "opening tag")
61 ;"Result: if aOpen,bOpen, and cOpen,dSelected are valid values, then
62 ;" will return value from CompArray, i.e.
63 ;" CompArray("opening tag",a,b,c,d)="x" <--- will return "x"
64 ;" otherwise returns 0
65
66 new a,b,c,d
67 new acount set acount=0
68 new bcount set bcount=0
69 new ccount set ccount=0
70 new dcount set dcount=0
71 new result set result=0
72
73 write #,!
74
75 set a=$order(CompArray(ByTag,""))
76 if a'="" for do quit:(a="")
77 . set acount=acount+1
78 . new nexta set nexta=$order(CompArray(ByTag,a))
79 . new Aindent
80 . if (aOpen=0) do
81 . . if acount<10 write "0"
82 . . write acount,". "
83 . else write "... "
84 . write a,!
85 . set b=$order(CompArray(ByTag,a,""))
86 . if (aOpen=acount)&(b'="") for do quit:(b="")
87 . . set bcount=bcount+1
88 . . new nextb set nextb=$order(CompArray(ByTag,a,b))
89 . . new Bindent
90 . . write " +--"
91 . . if (bOpen=0) do
92 . . . if bcount<10 write "0"
93 . . . write bcount,". "
94 . . else write "... "
95 . . write b,!
96 . . if nextb'="" set Aindent=" | "
97 . . else set Aindent=" "
98 . . set c=$order(CompArray(ByTag,a,b,""))
99 . . if (bOpen=bcount)&(c'="") for do quit:(c="")
100 . . . set ccount=ccount+1
101 . . . new nextc set nextc=$order(CompArray(ByTag,a,b,c))
102 . . . if nextc'="" set Bindent=" | "
103 . . . else set Bindent=" "
104 . . . write Aindent," +--"
105 . . . if (cOpen=0) do
106 . . . . if ccount<10 write "0"
107 . . . . write ccount,". "
108 . . . else write "... "
109 . . . write c,!
110 . . . set d=$order(CompArray(ByTag,a,b,c,""))
111 . . . if (cOpen=ccount)&(d'="") for do quit:(d="")
112 . . . . set dcount=dcount+1
113 . . . . write Aindent,Bindent," +-- "
114 . . . . if dcount<10 write "0"
115 . . . . write dcount,". "
116 . . . . write d,!
117 . . . . if dcount=dSelected set result=$get(CompArray(ByTag,a,b,c,d))
118 . . . . set d=$order(CompArray(ByTag,a,b,c,d))
119 . . . set c=nextc
120 . . set b=nextb
121 . set a=nexta
122
123SBDone
124 quit result
125
126
Note: See TracBrowser for help on using the repository browser.