Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XTLKKWL2

XTLKKWL2.m

Go to the documentation of this file.
XTLKKWL2 ; IHS/OHPRD/ACC,ALB/JLU,SFISC/JC- PART 3 OF LOOKUP CONTROL PROGRAM FOR "AND"ING INVERTED SEARCH ;07/22/93  15:47
 ;;7.3;TOOLKIT;;Apr 25, 1995
 ; XTLKKWCT,XTLKREF,XTLKREF2 ARE PASSED IN AND SHOULD NOT BE KILLED
 ; THE FOLLOWING ARE PASSED OUT AND SHOULD NOT BE KILLED:
 ;  ^TMP($J,"ADFN"),^TMP($J,"AWRD"),XTLKDFN(),XTLKNUSE(),XTLKNWDS,
 ;  XTLKPRTL(),XTLKWORD()
 ;
PREPSCH ; PREPARE FOR SEARCH BY BUILDING WORD/DFN TABLES
 S XTLKNWDS=0
 G:$O(XTLKWT(""))="" PREPSCHX
 S XTLKNWS=^DD("KWIC")_"^IN^OF^AN^IS^AS^AT^IF^IT^ON^OR^BY^"
 W:XTLKSAY=1 "("
 S XTLKWD=""=0
 F XTLKQ=0:0 S XTLKWD=$O(XTLKWT(XTLKWD)) Q:XTLKWD=""  D WDCHK
 W:XTLKSAY=1 " )",!
PREPSCHX K XTLKWT,XTLKNWS,XTLKWD,XTLKQ
 K XTLKEXAC,XTLKPART,XTLKSYN,XTLKINCR
 Q
 ;
WDCHK ; DETERMINE IF PARTIAL OR EXACT MATCH
 S XTLKWSAV=XTLKWD
 S (XTLKISNT,XTLKFXAC)=0
RECHK I $E(XTLKWD)="'" S XTLKISNT=1,XTLKWD=$E(XTLKWD,2,255) G RECHK
 I $E(XTLKWD)="~" S XTLKFXAC=1,XTLKWD=$E(XTLKWD,2,255) G RECHK
 I XTLKWD?1N.E!(XTLKNWS[("^"_XTLKWD_"^")) S XTLKNUSE=XTLKNUSE+1,XTLKNUSE(XTLKWD)="" G WDCHKX
 S XTLKINCR=0,XTLKSYN=$D(^XT(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