XTLKKSCH ; IHS/OHPRD/ACC,SFISC/JC - "AND"ING INVERTED LIST SEARCH ;07/22/93 15:45
;;7.3;TOOLKIT;;Apr 25, 1995
; XTLKNWDS,XTLKREF1,XTLKREF4,XTLKWORD() ARE PASSED IN AND
; SHOULD NOT BE KILLED
K ^TMP("XTLKHITS",$J) S ^TMP("XTLKHITS",$J)=0
I $D(XTLKHLIM) S XTLKHLM1=XTLKHLIM+1
E S XTLKHLM1=0
S XTLKCMAX=XTLKDFN(1) F XTLKI=1:1:XTLKNWDS S:XTLKDFN(XTLKI)<XTLKCMAX XTLKCMAX=XTLKDFN(XTLKI)
RESTRT ;
S XTLKI=0,XTLKEMTY=0
SCLOOP ;
S XTLKI=XTLKI+1
G:XTLKI>XTLKNWDS!(XTLKEMTY) ENDCHK
CMP S XTLKLOW=XTLKDFN(XTLKI)<XTLKCMAX,XTLKHIGH=XTLKDFN(XTLKI)>XTLKCMAX
I XTLKLOW D INCSTK:XTLKPRTL(XTLKI),INCONE:'XTLKPRTL(XTLKI) G:'XTLKEMTY CMP
I XTLKHIGH S XTLKCMAX=XTLKDFN(XTLKI),XTLKI=0
G SCLOOP
ENDCHK ;
G:XTLKEMTY EXIT
D NOTCHK W:XTLKSAY=1 "." D:'XTLKELIM CHKSCRN
I 'XTLKELIM S ^TMP("XTLKHITS",$J)=^TMP("XTLKHITS",$J)+1,^TMP("XTLKHITS",$J,^TMP("XTLKHITS",$J))=XTLKCMAX,XTLKHLM1=XTLKHLM1-1 G:XTLKHLM1=0 STOP
S XTLKCMAX=XTLKCMAX+1
G RESTRT
STOP W !,"Too many terms meet your criteria; please refine your search.",! K ^TMP("XTLKHITS",$J) S ^TMP("XTLKHITS",$J)=0
EXIT K XTLKEMTY,XTLKHIGH,XTLKLOW,XTLKMDFN,XTLKNUM,XTLKCMAX,XTLKHLM1
K XTLKPRTL,XTLKWORD,XTLKAWRD,XTLKDFN,XTLKADFN,XTLKELIM
K XTLKWD,XTLKD,XTLKI,XTLKJ,XT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S:XTLKD'="" ^TMP($J,"ADFN",XTLKI,XTLKJ)=XTLKD
K:XTLKD="" ^TMP($J,"AWRD",XTLKI,XTLKJ),^TMP($J,"ADFN",XTLKI,XTLKJ)
Q
XTLKKSCH ; IHS/OHPRD/ACC,SFISC/JC - "AND"ING INVERTED LIST SEARCH ;07/22/93 15:45
+1 ;;7.3;TOOLKIT;;Apr 25, 1995
+2 ; XTLKNWDS,XTLKREF1,XTLKREF4,XTLKWORD() ARE PASSED IN AND
+3 ; SHOULD NOT BE KILLED
+4 KILL ^TMP("XTLKHITS",$JOB)
SET ^TMP("XTLKHITS",$JOB)=0
+5 IF $DATA(XTLKHLIM)
SET XTLKHLM1=XTLKHLIM+1
+6 IF '$TEST
SET XTLKHLM1=0
+7 SET XTLKCMAX=XTLKDFN(1)
FOR XTLKI=1:1:XTLKNWDS
IF XTLKDFN(XTLKI)<XTLKCMAX
SET XTLKCMAX=XTLKDFN(XTLKI)
RESTRT ;
+1 SET XTLKI=0
SET XTLKEMTY=0
SCLOOP ;
+1 SET XTLKI=XTLKI+1
+2 IF XTLKI>XTLKNWDS!(XTLKEMTY)
GOTO ENDCHK
CMP SET XTLKLOW=XTLKDFN(XTLKI)<XTLKCMAX
SET XTLKHIGH=XTLKDFN(XTLKI)>XTLKCMAX
+1 IF XTLKLOW
IF XTLKPRTL(XTLKI)
DO INCSTK
IF 'XTLKPRTL(XTLKI)
DO INCONE
IF 'XTLKEMTY
GOTO CMP
+2 IF XTLKHIGH
SET XTLKCMAX=XTLKDFN(XTLKI)
SET XTLKI=0
+3 GOTO SCLOOP
ENDCHK ;
+1 IF XTLKEMTY
GOTO EXIT
+2 DO NOTCHK
IF XTLKSAY=1
WRITE "."
IF 'XTLKELIM
DO CHKSCRN
+3 IF 'XTLKELIM
SET ^TMP("XTLKHITS",$JOB)=^TMP("XTLKHITS",$JOB)+1
SET ^TMP("XTLKHITS",$JOB,^TMP("XTLKHITS",$JOB))=XTLKCMAX
SET XTLKHLM1=XTLKHLM1-1
IF XTLKHLM1=0
GOTO STOP
+4 SET XTLKCMAX=XTLKCMAX+1
+5 GOTO RESTRT
STOP WRITE !,"Too many terms meet your criteria; please refine your search.",!
KILL ^TMP("XTLKHITS",$JOB)
SET ^TMP("XTLKHITS",$JOB)=0
EXIT KILL XTLKEMTY,XTLKHIGH,XTLKLOW,XTLKMDFN,XTLKNUM,XTLKCMAX,XTLKHLM1
+1 KILL XTLKPRTL,XTLKWORD,XTLKAWRD,XTLKDFN,XTLKADFN,XTLKELIM
+2 KILL XTLKWD,XTLKD,XTLKI,XTLKJ,XTLKQ
+3 QUIT
+4 ;
NOTCHK ; CHECK POSSIBLE HIT FOR ELIMINATION BY "NOT"
+1 SET XTLKELIM=0
SET XTLKD=XTLKCMAX
+2 SET XTLKJ=""
FOR XTLKQ=0:0
SET XTLKJ=$ORDER(^TMP($JOB,"AWRD",0,XTLKJ))
IF XTLKJ=""
QUIT
SET XTLKWD=^TMP($JOB,"AWRD",0,XTLKJ)
IF $DATA(@XTLKREF4)
SET XTLKELIM=1
QUIT
+3 QUIT
+4 ;
CHKSCRN ; CHECK SCREEN
+1 SET Y=XTLKCMAX
IF $DATA(@(XTLKREF1_"Y,0)"))
IF $DATA(DIC("S"))
XECUTE DIC("S")
IF '$TEST
SET XTLKELIM=1
+2 QUIT
+3 ;
INCONE ; ADVANCE DFN FOR EXACT MATCH CASE
+1 SET XTLKD=XTLKDFN(XTLKI)
SET XTLKWD=XTLKWORD(XTLKI)
+2 IF XTLKD<XTLKCMAX
SET XTLKD=XTLKCMAX-1
+3 FOR XTLKQ=0:0
SET XTLKD=$ORDER(@XTLKREF4)
IF XTLKD=""!(XTLKD'<XTLKCMAX)
QUIT
+4 SET XTLKDFN(XTLKI)=XTLKD
+5 IF XTLKD=""
SET XTLKEMTY=1
+6 QUIT
+7 ;
INCSTK ; ADVANCE COMPOSITE DFN FOR PARTIAL MATCH CASE
+1 SET XTLKJ=0
+2 FOR XTLKQ=0:0
SET XTLKJ=$ORDER(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