source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXSQL3.m@ 1181

Last change on this file since 1181 was 1087, checked in by Sam Habiel, 14 years ago

BMX updated to v2.3. No actual routine changes from 2.21

File size: 13.5 KB
Line 
1BMXSQL3 ; IHS/OIT/HMW - BMX REMOTE PROCEDURE CALLS ;
2 ;;2.3;BMX;;Jan 25, 2011
3 ;
4 ;
5PLEVEL(BMXFF,BMXLVL,BMXRET) ;EP
6 ;Analyze WHERE statement according to paren level
7 ;Return a string to guide building of iterator(s)
8 ;
9 ;Basically, count the number of OR clauses on the
10 ;same paren level
11 ;IN: BMXFF()
12 ;OUT: BMXLVL(), BMXRET
13 ;
14 ;BMXRET = 1&/!2&/!...&/!n clauses
15 ;BMXLVL(E,"BEGIN")=Index where element E begins
16 ;BMXLVL(E,"END") =Index where element E ends
17 ;BMXLVL(E,"ELEMENTS")=Number of subelements in element E
18 ;
19 N BMXNOR,BMXNAND,J,C,BMXTMP
20 N E,L,BMXCNT
21 ;Test for no ORs or no ANDs
22 S BMXNOR=1,BMXNAND=1
23 S J=0 F S J=$O(BMXFF(J)) Q:'+J D ;Q:'BMXNOR Q:'BMXNAND
24 . I BMXFF(J)="OR" S BMXNOR=0
25 . I BMXFF(J)="AND" S BMXNAND=0
26 . Q
27 ;If no ORs or no ANDs then take all parens out of BMXFF
28 I ((BMXNOR)!(BMXNAND)) D
29 . S:$D(BMXFF("INDEX")) BMXTMP("INDEX")=BMXFF("INDEX")
30 . S J=0,C=0 F S J=$O(BMXFF(J)) Q:'+J D:"(^)"'[BMXFF(J)
31 . . S C=C+1
32 . . S BMXTMP(C)=BMXFF(J)
33 . . S:$D(BMXFF(J,0)) BMXTMP(C,0)=BMXFF(J,0)
34 . . S:$D(BMXFF(J,"INTERNAL")) BMXTMP(J,"INTERNAL")=BMXFF(J,"INTERNAL")
35 . . S:$D(BMXFF(J,"TYPE")) BMXTMP(C,"TYPE")=BMXFF(J,"TYPE")
36 . . S:$D(BMXFF(J,"IEN")) BMXTMP(C,"IEN")=BMXFF(J,"IEN")
37 . . S:$D(BMXFF(J,"JOIN")) BMXTMP(C,"JOIN")=BMXFF(J,"JOIN")
38 . . S:$D(BMXFF(J,"JOIN","IEN")) BMXTMP(C,"JOIN","IEN")=BMXFF(J,"JOIN","IEN")
39 . . ;I $D(BMXFF(J,"JOIN")) D
40 . . ;. N K S K=0 F S K=$O(BMXFF(J,"JOIN",K)) Q:'+K D
41 . . ;. . N L S L=0 F S L=$O(BMXFF(J,"JOIN",K,L)) Q:'+L D
42 . . ;. . . S BMXTMP(C,"JOIN",K,L)=BMXFF(J,"JOIN",K,L)
43 . . I $D(BMXFF(J,"SET")) D
44 . . . N BMXSS
45 . . . S BMXSS="" F S BMXSS=$O(BMXFF(J,"SET",BMXSS)) Q:BMXSS="" D
46 . . . . S BMXTMP(C,"SET",BMXSS)=BMXFF(J,"SET",BMXSS)
47 . K BMXFF
48 . I $D(BMXTMP("INDEX")) S BMXFF("INDEX")=BMXTMP("INDEX")
49 . S J=0 F S J=$O(BMXTMP(J)) Q:'+J D
50 . . S BMXFF(J)=BMXTMP(J)
51 . . S:$D(BMXTMP(J,0)) BMXFF(J,0)=BMXTMP(J,0)
52 . . S:$D(BMXTMP(J,"TYPE")) BMXFF(J,"TYPE")=BMXTMP(J,"TYPE")
53 . . I $D(BMXTMP(J,"JOIN")) S BMXFF(J,"JOIN")=BMXTMP(J,"JOIN") S:$D(BMXTMP(J,"JOIN","IEN")) BMXFF(J,"JOIN","IEN")=BMXTMP(J,"JOIN","IEN") S BMXFJ("JOIN",+$P($P(BMXFF(J,0),U,2),"P",2))=J
54 . . ;I $D(BMXTMP(J,"JOIN")) D
55 . . ;. N K S K=0 F S K=$O(BMXTMP(J,"JOIN",K)) Q:'+K D
56 . . ;. . N L S L=0 F S L=$O(BMXTMP(J,"JOIN",K,L)) Q:'+L D
57 . . ;. . . S BMXFF(J,"JOIN",K,L)=BMXTMP(J,"JOIN",K,L)
58 . . I $D(BMXTMP(J,"SET")) D
59 . . . N BMXSS
60 . . . S BMXSS="" F S BMXSS=$O(BMXTMP(J,"SET",BMXSS)) Q:BMXSS="" D
61 . . . . S BMXFF(J,"SET",BMXSS)=BMXTMP(J,"SET",BMXSS)
62 . . I $D(BMXTMP(J,"INTERNAL")) S BMXFF(J,"INTERNAL")=BMXTMP(J,"INTERNAL")
63 . . I $D(BMXTMP(J,"IEN")) S BMXFF(J,"IEN")=BMXTMP(J,"IEN")
64 . S BMXFF=C
65 . Q
66 ;
67 ;Remove excess leading and trailing parens
68 ;Find close paren corresponding to BMXFF(1)
69 ;If its the last paren, then remove the first and last parens
70 ;Else, quit
71 N BMXEND
72 S BMXEND=0
73 F Q:'((BMXFF(1)="(")&(BMXFF(BMXFF)=")")) Q:BMXEND D
74 . S L=1,J=1
75 . F S J=$O(BMXFF(J)) Q:'+J D:"(^)"[BMXFF(J) Q:BMXEND
76 . . I BMXFF(J)="(" S L=L+1 Q
77 . . I BMXFF(J)=")" S L=L-1
78 . . I L=0,J<BMXFF S BMXEND=1 Q
79 . . I L=0,J=BMXFF D Q
80 . . . K BMXFF(1),BMXFF(BMXFF)
81 . . . F J=2:1:BMXFF-1 D
82 . . . . S BMXFF(J-1)=BMXFF(J)
83 . . . . S:$D(BMXFF(J,0)) BMXFF(J-1,0)=BMXFF(J,0)
84 . . . . K BMXFF(J)
85 . . . S BMXFF=BMXFF-2
86 ;
87 S BMXRET="",E=1,L=0,BMXCNT=0
88 K BMXLVL
89 S J=0 F S J=$O(BMXFF(J)) Q:'+J D
90 . I BMXFF(J)="(" D Q ;If BMXFF(J) is an open paren
91 . . S L=1
92 . . S BMXLVL(E,"BEGIN")=J ;Start position of this expression
93 . . S BMXCNT=0
94 . . ;Find corresponding close paren
95 . . F S J=$O(BMXFF(J)) Q:'+J D Q:L=0
96 . . . I BMXFF(J)=")" S L=L-1,BMXLVL(E,"END")=J,BMXLVL(E,"ELEMENTS")=BMXCNT Q
97 . . . I BMXFF(J)="(" S L=L+1 Q
98 . . . I "AND^OR"'[BMXFF(J) S BMXCNT=BMXCNT+1
99 . . S BMXRET=BMXRET_E
100 . . S E=E+1
101 . . Q
102 . I "AND^OR"[BMXFF(J) D Q ;If BMXFF(J) is an operator
103 . . S BMXRET=BMXRET_$S(BMXFF(J)="OR":"!",1:"&")
104 . D Q ; BMXFF(J) is an element unenclosed by parens
105 . . S BMXLVL(E,"BEGIN")=J
106 . . S BMXLVL(E,"END")=J
107 . . S BMXLVL(E,"ELEMENTS")=1
108 . . S BMXRET=BMXRET_E
109 . . S E=E+1
110 . Q
111 Q
112 ;
113XRTST(BMXFF,F,BMXHIT,BMXRNAM,BMXPFP) ;EP
114 ;Returns TRUE (1) in BMXRET if 'normal' index exists
115 ;for field in BMXFF(BMXNDX)
116 ;ELSE returns 0
117 ;
118 ;IN: BMXFF
119 ; F
120 ;OUT:BMXRET - 1 or 0
121 ; BMXRNAM - If BMXRET=1, Index name
122 ;
123 N BMXNOD0,BMXFNUM,BMXGL,BMXFLDNUM,BMXREF,Q
124 S BMXRET=0,Q=$C(34)
125 ;
126 Q:"AND^OR^(^)"[BMXFF(F)
127 S BMXNOD=BMXFF(F)
128 S BMXNOD0=BMXFF(F,0)
129 S BMXFNUM=$P(BMXNOD,U,5)
130 Q:'+BMXFNUM
131 S BMXGL=$P(BMXNOD,U,7,8)
132 S BMXFLDNUM=$P(BMXNOD,U,6)
133 S BMXHIT=0
134 Q:$D(BMXFF("JOIN"))
135 Q:$D(BMXFF(F,"INTERNAL"))
136 I BMXPFF=0,$P(BMXFF(F),U,4)="" Q ;Cannot create iterator on null
137 I $D(BMXFF(F,"IEN")) S BMXHIT=1 Q
138 I '$D(^DD(BMXFNUM,BMXFLDNUM,1)) Q
139 I $P(BMXNOD0,U,2)'["P",$D(BMXFF("INDEX")) D Q ;Explicit index
140 . S BMXRNAM=BMXFF("INDEX")
141 . S BMXHIT=1
142 S BMXREF=0
143 F S BMXREF=$O(^DD(BMXFNUM,BMXFLDNUM,1,BMXREF)) Q:'+BMXREF Q:BMXHIT D
144 . Q:'$D(^DD(BMXFNUM,BMXFLDNUM,1,BMXREF,0))
145 . S BMXRNOD=^DD(BMXFNUM,BMXFLDNUM,1,BMXREF,0)
146 . Q:$P(BMXRNOD,U,3)]""
147 . S BMXRNAM=$P(BMXRNOD,U,2)
148 . S BMXTMP=BMXGL_Q_BMXRNAM_Q_")"
149 . Q:'$D(@BMXTMP)
150 . S BMXTMPV=0,BMXTMPV=$O(@BMXTMP@(BMXTMPV))
151 . Q:BMXTMPV=""
152 . S BMXTMP=BMXGL_Q_BMXRNAM_Q_","_Q_BMXTMPV_Q_")"
153 . S BMXTMPI=0,BMXTMPI=$O(@BMXTMP@(BMXTMPI))
154 . S BMXTMP=$S(BMXGL[",":$P(BMXGL,",")_")",1:$P(BMXGL,"("))
155 . Q:'$D(@BMXTMP@(BMXTMPI))
156 . S BMXTMPL=$P(BMXFF(F,0),U,4)
157 . S BMXTMPP=$P(BMXTMPL,";",2)
158 . S BMXTMPL=$P(BMXTMPL,";")
159 . Q:BMXTMPL=""
160 . S BMXTMP=BMXGL_BMXTMPI_")"
161 . Q:'$D(@BMXTMP@(BMXTMPL))
162 . S BMXTMPN=@BMXTMP@(BMXTMPL)
163 . I BMXTMPP["E" D
164 . . S BMXTMPP=$P(BMXTMPP,"E",2)
165 . . S BMXTMPP=$E(BMXTMPN,$P(BMXTMPP,","),$P(BMXTMPP,",",2))
166 . E D
167 . . S BMXTMPP=$P(BMXTMPN,"^",BMXTMPP)
168 . I $P(BMXNOD0,U,2)["P" D Q
169 . . N BMXPFFN
170 . . S BMXPFF(BMXPFF)=BMXFF(F)
171 . . S BMXPFF(BMXPFF,0)=BMXFF(F,0)
172 . . S BMXPFF(BMXPFF,1)=BMXREF
173 . . S $P(BMXPFF(BMXPFF,1),U,2)=BMXRNAM
174 . . S BMXPFP(BMXPFP,BMXPFF)=BMXFF(F)
175 . . S BMXPFP(BMXPFP,BMXPFF,0)=BMXFF(F,0)
176 . . S BMXPFP(BMXPFP,BMXPFF,1)=BMXREF
177 . . S $P(BMXPFP(BMXPFP,BMXPFF,1),U,2)=BMXRNAM
178 . . S BMXPFF=BMXPFF+1
179 . . S BMXPFFN=$P(BMXNOD0,U,2)
180 . . S BMXPFFN=+$P(BMXPFFN,"P",2)
181 . . S $P(BMXPFF(BMXPFF),U,5)=BMXPFFN
182 . . S $P(BMXPFF(BMXPFF),U,6)=".01"
183 . . S $P(BMXPFF(BMXPFF),U,7)=^DIC(BMXPFFN,0,"GL")
184 . . S BMXPFF(BMXPFF,0)=^DD(BMXPFFN,".01",0)
185 . . S $P(BMXPFP(BMXPFP,BMXPFF),U,5)=BMXPFFN
186 . . S $P(BMXPFP(BMXPFP,BMXPFF),U,6)=".01"
187 . . S $P(BMXPFP(BMXPFP,BMXPFF),U,7)=^DIC(BMXPFFN,0,"GL")
188 . . S BMXPFP(BMXPFP,BMXPFF,0)=^DD(BMXPFFN,".01",0)
189 . . D XRTST(.BMXPFF,BMXPFF,.BMXHIT,BMXRNAM,.BMXPFP)
190 . . Q
191 . I BMXTMPP=BMXTMPV D Q
192 . . S BMXHIT=1,BMXRET=1
193 . . I BMXPFF>0 D Q
194 . . . S BMXPFF(BMXPFF,1)=BMXREF
195 . . . S $P(BMXPFF(BMXPFF,1),U,2)=BMXRNAM
196 . . . S BMXPFP(BMXPFP,BMXPFF,1)=BMXREF
197 . . . S $P(BMXPFP(BMXPFP,BMXPFF,1),U,2)=BMXRNAM
198 . . Q
199 . Q
200 Q
201 ;
202 ;
203BLDIT(BMXFF,F,BMXRNAM,BMXRET,BMXPFP) ;EP - Build iterator
204 ;
205 K BMXRET
206 N BMXNOD,BMXOP,BMXV,BMXGL,Q
207 S BMXNOD=BMXFF(F)
208 S BMXOP=$P(BMXNOD,U,3)
209 S BMXV=$P(BMXNOD,U,4)
210 S BMXGL=$P(BMXNOD,U,7,8)
211 S Q=$C(34)
212 I $D(BMXPFP(F)) D BLDIT2 Q ;Pointer
213 ;TODO Set BMXV to the pointer or set or FM date that corresponds
214 ; to the user-entered value
215 I $D(BMXFF(F,"IEN")),BMXFF(F,"IEN")="TEMPLATE" D Q
216 . N BMXTNUM
217 . S BMXTNUM=$O(^DIBT("B",$P(BMXFF(F),U,4),0))
218 . S BMXRET="S D0=0 F S D0=$O(^DIBT("_BMXTNUM_",1,D0)) Q:'+D0 Q:BMXM>BMXXMAX "
219 . Q
220 I BMXOP="=" D Q
221 . I $D(BMXFF(F,"IEN")) S BMXRET="S D0="_BMXV_" Q:'+D0 Q:BMXM>BMXXMAX " Q
222 . S BMXRET="S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_","_Q_BMXV_Q_",D0)) Q:D0="""" Q:BMXM>BMXXMAX "
223 . Q
224 ;
225 I BMXOP=">=" D Q
226 . I $D(BMXFF(F,"IEN")) S BMXV=BMXV-1,BMXRET="S D0="_BMXV_" F S D0=$O("_BMXGL_"D0)) Q:'+D0 Q:BMXM>BMXXMAX " Q
227 . N BMXTMP
228 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1)"
229 . S @BMXTMP
230 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
231 ;
232 I BMXOP=">" D Q
233 . I $D(BMXFF(F,"IEN")) S BMXRET="S D0="_BMXV_" F S D0=$O("_BMXGL_"D0)) Q:'+D0 Q:BMXM>BMXXMAX " Q
234 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
235 ;
236 I BMXOP="<>" D Q
237 . I $D(BMXFF(F,"IEN")) S BMXRET="S D0=0 F S D0=$O("_BMXGL_"D0)) Q:'+D0 I D0'="_BMXV_" Q:BMXM>BMXXMAX " Q
238 . S BMXRET="S BMXV=0 F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX I BMXV'="_Q_BMXV_Q_" S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
239 ;
240 I BMXOP="<=" D Q
241 . I $D(BMXFF(F,"IEN")) S BMXRET="S D0=0 F S D0=$O("_BMXGL_"D0)) Q:'+D0 Q:D0>"_BMXV_" Q:BMXM>BMXXMAX " Q
242 . N BMXTMP
243 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV))"
244 . S @BMXTMP
245 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) Q:BMXV="""" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
246 ;
247 I BMXOP="<" D Q
248 . I $D(BMXFF(F,"IEN")) S BMXRET="S D0=0 F S D0=$O("_BMXGL_"D0)) Q:'+D0 Q:D0'<"_BMXV_" Q:BMXM>BMXXMAX " Q
249 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) Q:BMXV="""" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
250 ;
251 I BMXOP="BETWEEN" D Q ;changed '< to > (inclusive BETWEEN)
252 . I $D(BMXFF(F,"IEN")) D Q
253 . . S BMXRET="S D0="_(+$P(BMXV,"~")-1)_" F S D0=$O("_BMXGL_"D0)) Q:'+D0 Q:D0>"_$P(BMXV,"~",2)_" Q:BMXM>BMXXMAX "
254 . I +$P(BMXV,"~")=$P(BMXV,"~") D ;BMXV is a number
255 . . S BMXRET="S BMXV="_$P(BMXV,"~")_",BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q
256 . . S BMXRET=BMXRET_",BMXV)) Q:BMXV="""" Q:BMXV>"_$P(BMXV,"~",2)_" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
257 . E D ;BMXV is a string
258 . . S BMXRET="S BMXV="_Q_$P(BMXV,"~")_Q_",BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q
259 . . S BMXRET=BMXRET_",BMXV)) Q:BMXV="""" Q:BMXV]"_Q_$P(BMXV,"~",2)_Q_" Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
260 ;
261 I BMXOP="LIKE" D Q
262 . N BMXTMP,BMXV1
263 . S BMXV1=BMXV
264 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1)"
265 . S @BMXTMP
266 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXV'?1"_Q_BMXV1_Q_".E Q:BMXM>BMXXMAX S D0="""" F S D0=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D0)) Q:D0="""" Q:BMXM>BMXXMAX "
267 Q
268 ;
269BLDIT2 ;Pointer
270 N BMXPS,J
271 S BMXPS=$O(BMXPFP(F,999),-1)
272 S BMXNOD=BMXPFP(F,BMXPS)
273 S BMXGL=$P(BMXNOD,U,7,8)
274 I BMXOP="=" D
275 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
276 . S BMXRET="S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_","_Q_BMXV_Q_",D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
277 ;
278 I BMXOP=">" D
279 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
280 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
281 ;
282 I BMXOP=">=" D
283 . N BMXTMP
284 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
285 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1)"
286 . S @BMXTMP
287 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
288 ;
289 I BMXOP="<=" D
290 . N BMXTMP
291 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
292 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV))"
293 . S @BMXTMP
294 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) Q:BMXV="""" Q:BMXM>BMXXMAX S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
295 ;
296 I BMXOP="<>" D
297 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
298 . S BMXRET="S BMXV=0 F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXM>BMXXMAX I BMXV'="_Q_BMXV_Q_" S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
299 ;
300 I BMXOP="<" D
301 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
302 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) Q:BMXV="""" Q:BMXM>BMXXMAX S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
303 ;
304 I BMXOP="BETWEEN" D
305 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
306 . I +$P(BMXV,"~")=$P(BMXV,"~") D ;BMXV is a number
307 . . S BMXRET="S BMXV="_$P(BMXV,"~")_",BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q
308 . . S BMXRET=BMXRET_",BMXV)) Q:BMXV="""" Q:BMXV>"_$P(BMXV,"~",2)_" Q:BMXM>BMXXMAX S D"_BMXPS_"=0 F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
309 . E D ;BMXV is a string
310 . . S BMXRET="S BMXV="_Q_$P(BMXV,"~")_Q_",BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1) F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q
311 . . S BMXRET=BMXRET_",BMXV)) Q:BMXV="""" Q:BMXV]"_Q_$P(BMXV,"~",2)_Q_" Q:BMXM>BMXXMAX S D"_BMXPS_"=0 F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
312 ;
313 I BMXOP="LIKE" D
314 . N BMXTMP,BMXV1
315 . S BMXRNAM=$P(BMXPFP(F,BMXPS,1),U,2)
316 . S BMXV1=BMXV
317 . S BMXTMP="BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV),-1)"
318 . S @BMXTMP
319 . S BMXRET="S BMXV="_Q_BMXV_Q_" F S BMXV=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV)) Q:BMXV="""" Q:BMXV'?1"_Q_BMXV1_Q_".E Q:BMXM>BMXXMAX S D"_BMXPS_"="""" F S D"_BMXPS_"=$O("_BMXGL_Q_BMXRNAM_Q_",BMXV,D"_BMXPS_")) Q:'+D"_BMXPS_" Q:BMXM>BMXXMAX "
320 ;
321 F J=BMXPS-1:-1:0 D
322 . S BMXNOD=BMXPFP(F,J)
323 . S BMXGL=$P(BMXNOD,U,7,8)
324 . S BMXRNAM=$P(BMXPFP(F,J,1),U,2)
325 . S BMXRET=BMXRET_"S D"_J_"=0 F S D"_J_"=$O("_BMXGL_Q_BMXRNAM_Q_",D"_(J+1)_",D"_J_")) Q:'+D"_J_" Q:BMXM>BMXXMAX "
326 Q
327 ;TODO: Computed fields
328 ;TODO: Sets of codes
329 ;TODO: User-specified index
330 Q
Note: See TracBrowser for help on using the repository browser.