212 lines
9.2 KiB
Mathematica
212 lines
9.2 KiB
Mathematica
XMJMFB ;ISC-SF/GMB-Find message: multiple conditions ;07/12/2002 10:40
|
|
;;8.0;MailMan;;Jun 28, 2002
|
|
; Replaces ^XMAL0,^XMAL0A (ISC-WASH/JSH/CAP)
|
|
; XMF("BSKT") =number - Look in this basket ONLY
|
|
; =* - Look in all baskets
|
|
; XMF("SUBJ") Subject contains this string
|
|
; XMF("SUBJ","S") Look for this string in the subject
|
|
; XMF("FLINE") Message has this many or more lines
|
|
; XMF("TLINE") Message has this many or fewer lines
|
|
; XMF("FROM") Message is from this person
|
|
; XMF("TO") Message is to this person
|
|
; XMF("FDATE") Message was sent on or after this date
|
|
; XMF("TDATE") Message was sent on or before this date
|
|
; XMF("RFROM") Message has a response from this person
|
|
; XMF("TEXT") Message contains this string
|
|
; XMF("TEXT","S") Look for this string in the message
|
|
; XMF("TEXT","L") =1 - Look in message only
|
|
; =2 - Look in both message and responses
|
|
; =3 - Look in responses only
|
|
; XMF("TEXT","C") =0 - Search is not case-sensitive
|
|
; =1 - Search is case-sensitive
|
|
FIND1(XMDUZ,XMF,XMWAIT) ;
|
|
N XMK,XMKN,XMKZ,XMCNT,XMABORT,XMLEN,XMFIRST,XMPAGE,XMDETAIL,XMPMAX,XMMORE,XMZOOM,XMCD,XMOPT,XMOX
|
|
K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
|
|
S XMKZ="",(XMPAGE,XMCNT,XMZOOM,XMCD,XMABORT)=0,(XMDETAIL,XMMORE)=1,XMPMAX=IOSL-3
|
|
D INIT1(XMDUZ,.XMF,XMDETAIL,XMPMAX,.XMK,.XMKN,.XMLEN)
|
|
D SETOPT^XMJMLR1(XMDUZ,$S(XMDUZ'=.5:0,XMK<1000:0,1:XMK),.XMOPT,.XMOX)
|
|
F D Q:XMABORT
|
|
. I XMCD S XMCD=0,XMDETAIL='XMDETAIL D INIT1(XMDUZ,.XMF,XMDETAIL,XMPMAX,.XMK,.XMKN,.XMLEN)
|
|
. D DISPLAY1(XMDUZ,.XMF,XMDETAIL,.XMK,XMKN,.XMKZ,.XMCNT,.XMFIRST,.XMPAGE,.XMMORE,.XMLEN,XMZOOM,XMPMAX)
|
|
. I XMCNT=0 S XMABORT=1 Q
|
|
. D CHOOSE^XMJMLN(XMDUZ,0,XMK,.XMKZ,.XMFIRST,.XMPAGE,XMMORE,.XMLEN,.XMZOOM,.XMOPT,.XMOX,"READMSG^XMJMFB",.XMABORT)
|
|
. S:'$D(^TMP("XM",$J,"MSG")) XMABORT=1
|
|
I XMCNT=0 D
|
|
. W $C(7),$$EZBLD^DIALOG(34401) ; No matches found.
|
|
. Q:'$G(XMWAIT)
|
|
. W ! D WAIT^XMXUTIL
|
|
K ^TMP("XM",$J,"MSG"),^TMP("XM",$J,".")
|
|
Q
|
|
INIT1(XMDUZ,XMF,XMDETAIL,XMPMAX,XMK,XMKN,XMLEN) ;
|
|
S:$D(XMF("SUBJ")) XMF("SUBJ","S")=$$UP^XLFSTR(XMF("SUBJ"))
|
|
S:$D(XMF("TEXT")) XMF("TEXT","S")=$S('XMF("TEXT","C"):$$UP^XLFSTR(XMF("TEXT")),1:XMF("TEXT"))
|
|
S XMK=XMF("BSKT")
|
|
S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
|
|
D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN,1)
|
|
Q
|
|
DISPLAY1(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZ,XMCNT,XMFIRST,XMPAGE,XMMORE,XMLEN,XMZOOM,XMPMAX) ;
|
|
N XMREC,XMZ
|
|
S XMFIRST(XMPAGE)=XMKZ
|
|
D HEADER^XMJML(XMDETAIL,.XMLEN,$$EZBLD^DIALOG(34404,XMKN)) ; XMKN_ Basket Search
|
|
I XMZOOM D Q
|
|
. F S XMKZ=$O(^TMP("XM",$J,".",XMKZ),XMV("ORDER")) Q:XMKZ="" D Q:$Y>XMPMAX
|
|
. . S XMREC=^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. . Q:'$$GOODMSG(XMDUZ,XMK,XMZ,.XMF)
|
|
. . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U)
|
|
I $D(XMKN) S XMKZZ=XMKZZ-XMV("ORDER") Q
|
|
S XMABORT=1
|
|
W $C(7),$$EZBLD^DIALOG(34401),! ; No matches found.
|
|
D WAIT^XMXUTIL
|
|
Q
|
|
DISPLAYA(XMDUZ,XMF,XMDETAIL,XMK,XMKN,XMKZZ,XMKZ,XMCNT,XMFIRST,XMPAGE,XMMORE,XMLEN,XMZOOM,XMPMAX) ;
|
|
N XMREC,XMZ
|
|
S XMFIRST(XMPAGE)=XMKZ
|
|
I XMCD D
|
|
. S XMCD=0,XMDETAIL='XMDETAIL
|
|
. D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN)
|
|
E I $L(XMCNT+XMPMAX)>XMLEN("XMKZ") D
|
|
. S XMLEN("XMKZ")=$L(XMCNT+XMPMAX)
|
|
. D INIT^XMJML(XMDUZ,XMK,XMKN,XMDETAIL,.XMLEN)
|
|
D HEADER^XMJML(XMDETAIL,.XMLEN,$$EZBLD^DIALOG(34405)) ; All Baskets Search
|
|
I XMZOOM D Q
|
|
. F S XMKZ=$O(^TMP("XM",$J,".",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
|
|
. . S XMREC=^TMP("XM",$J,"MSG",XMKZ)
|
|
. . D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
|
|
F S XMKZ=$O(^TMP("XM",$J,"MSG",XMKZ)) Q:XMKZ="" D Q:$Y>XMPMAX
|
|
. S XMREC=^TMP("XM",$J,"MSG",XMKZ)
|
|
. D LISTMSG^XMJML($P(XMREC,U,1),$P(XMREC,U,2),XMKZ,$P(XMREC,U,3),XMDETAIL,.XMLEN)
|
|
Q:$Y>XMPMAX!'XMMORE
|
|
S XMK=XMK-.01
|
|
F S XMK=$O(^XMB(3.7,X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P(XMZREC,U,1))'[XMF("SUBJ","S") Q 0
|
|
I $D(XMF("FROM")) Q:'$$GOODFROM(XMZREC,XMF("FROM")) 0
|
|
I $D(XMF("FLINE"))!$D(XMF("TLINE")) D Q:XMNOGOOD 0
|
|
. N XMLINES
|
|
. S XMNOGOOD=1
|
|
. S XMLINES=$$LINE^XMXUTIL2(XMZ)
|
|
. I $D(XMF("FLINE")),XMLINES<XMF("FLINE") Q
|
|
. I $D(XMF("TLINE")),XMF("TLINE")<XMLINES Q
|
|
. S XMNOGOOD=0
|
|
I $D(XMF("FDATE"))!$D(XMF("TDATE")) D Q:XMNOGOOD 0
|
|
. S XMNOGOOD=1
|
|
. S XMZDATE=$P(XMZREC,U,3)
|
|
. S:XMZDATE'=+XMZDATE XMZDATE=$$CONVERT^XMXUTIL1(XMZDATE)
|
|
. S XMZDATE=$P(XMZDATE,".")
|
|
. I $D(XMF("FDATE")),XMZDATE<XMF("FDATE") Q
|
|
. I $D(XMF("TDATE")),XMF("TDATE")<XMZDATE Q
|
|
. S XMNOGOOD=0
|
|
I $D(XMF("TO")) D Q:XMNOGOOD 0
|
|
. I $D(^XMB(3.9,XMZ,6,"B",XMF("TO"))) S XMNOGOOD=0 Q
|
|
. I $L(XMF("TO"))>30,$D(^XMB(3.9,XMZ,6,"B",$E(XMF("TO"),1,30))),XMF("TO")=$P($G(^XMB(3.9,XMZ,6,+$O(^XMB(3.9,XMZ,6,"B",$E(XMF("TO"),1,30),0)),0)),U,1) S XMNOGOOD=0 Q
|
|
. S XMNOGOOD=1
|
|
. Q:XMF("TO")'["@"
|
|
. N XMTOX,XMTO
|
|
. S XMTO=""
|
|
. F S XMTO=$O(^XMB(3.9,XMZ,6,"B",XMTO)) Q:XMTO="" D Q:'XMNOGOOD
|
|
. . Q:XMTO'["@"
|
|
. . S XMTOX=$$UP^XLFSTR(XMTO)
|
|
. . Q:$P(XMTOX,"@")'[$P(XMF("TO"),"@")
|
|
. . Q:$P(XMTOX,"@",2)'[$P(XMF("TO"),"@",2)
|
|
. . S XMNOGOOD=0
|
|
I $D(XMF("RFROM")) D Q:XMNOGOOD 0
|
|
. N XMIEN,XMZR
|
|
. S XMNOGOOD=1
|
|
. S XMIEN=0
|
|
. F S XMIEN=$O(^XMB(3.9,XMZ,3,XMIEN)) Q:'XMIEN S XMZR=^(XMIEN,0) I $$GOODFROM($G(^XMB(3.9,XMZR,0)),XMF("RFROM")) S XMNOGOOD=0 Q
|
|
I $D(XMF("TEXT")) D Q:XMNOGOOD 0
|
|
. S XMNOGOOD=1
|
|
. I XMF("TEXT","L")<3 D Q:XMF("TEXT","L")=1!(XMNOGOOD=0)
|
|
. . S:$$GOODTEXT(XMZ,XMF("TEXT","S"),XMF("TEXT","C")) XMNOGOOD=0
|
|
. N XMIEN,XMZR
|
|
. S XMIEN=0
|
|
. F S XMIEN=$O(^XMB(3.9,XMZ,3,XMIEN)) Q:'XMIEN S XMZR=^(XMIEN,0) I $$GOODTEXT(XMZR,XMF("TEXT","S"),XMF("TEXT","C")) S XMNOGOOD=0 Q
|
|
Q 1
|
|
GOODFROM(XMZREC,XMF) ; Returns 1 if msg is from XMF; 0 if not
|
|
N XMZFROM
|
|
S XMZFROM=$P(XMZREC,U,2)
|
|
I XMF=+XMF,XMF=XMZFROM Q 1
|
|
Q:XMF'["@" 0
|
|
S XMZFROM=$$UP^XLFSTR(XMZFROM)
|
|
Q:$P(XMZFROM,"@")'[$P(XMF,"@") 0
|
|
Q:$P(XMZFROM,"@",2)'[$P(XMF,"@",2) 0
|
|
Q 1
|
|
GOODTEXT(XMZ,XMF,XMFMATTR) ; Returns positive number if msg contains XMF; 0 if not
|
|
N I
|
|
S I=.999999
|
|
I XMFMATTR D
|
|
. F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I Q:^(I,0)[XMF
|
|
E D
|
|
. F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I Q:$$UP^XLFSTR(^(I,0))[XMF
|
|
Q +I
|
|
READMSG ; (XMDUZ,XMKZ,XMREC) <- needed!
|
|
N XMK,XMKN,XMZ,XMRDR ; $G(XMRDR) is checked in READMSG^XMJBM
|
|
S XMK=$P(XMREC,U,1),XMKN=$P(XMREC,U,2),XMZ=$P(XMREC,U,3)
|
|
D READMSG^XMJBM(XMDUZ,XMK,XMKN,XMZ)
|
|
Q:$D(^XMB(3.7,"M",XMZ,XMDUZ,XMK))
|
|
I XMF("BSKT")=XMK K ^TMP("XM",$J,"MSG",XMKZ) Q
|
|
S XMK=+$O(^XMB(3.7,"M",XMZ,XMDUZ,0))
|
|
S ^TMP("XM",$J,"MSG",XMKZ)=XMK_U_$S(XMK=0:$$EZBLD^DIALOG(34014),1:$P(^XMB(3.7,XMDUZ,2,XMK,0),U))_U_XMZ ; * N/A *
|
|
Q
|