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

AICDKWIC.m

Go to the documentation of this file.
AICDKWIC ; KWIC ROUTINE FOR LOOKUP ENGINE ;
 ;;4.0;AICD;;DEC 03, 2014;Build 7
S N AICDSWB,AICDOST,AICDST,AICDLLEN,AICDC,AICDD,AICDI,AICDJ,AICDWF,AICDWS,AICDWD,AICDWD2,AICDWL,AICDEND,AICDQ
 S AICDD=%,AICDL=X D TOKENIZE S AICDI="" F AICDJ=0:0 S AICDI=$O(AICDWT(AICDI)) Q:AICDI=""  I ^DD("KWIC")'[("^"_AICDI_"^") S @AICDD=""
 G QUIT
K N AICDSWB,AICDOST,AICDST,AICDLLEN,AICDC,AICDD,AICDI,AICDJ,AICDWF,AICDWS,AICDWD,AICDWD2,AICDWL,AICDEND,AICDQ
 S AICDD=%,AICDL=X D TOKENIZE S AICDI="" F AICDJ=0:0 S AICDI=$O(AICDWT(AICDI)) Q:AICDI=""  I ^DD("KWIC")'[("^"_AICDI_"^") K:'($D(@AICDD)\10) @AICDD
QUIT K AICDL,AICDWT,AICDI,AICDJ Q
TOKENIZE ; CONVERT INPUT LINE TO TOKENS ; [ 03/20/86  12:44 PM ]
 K AICDWT
 D CONVERT
 K AICDSWB,AICDOST,AICDST,AICDLLEN,AICDC,AICDI,AICDJ,AICDWF,AICDWS,AICDWD,AICDWD2,AICDWL,AICDEND,AICDQ
 Q
 ;
CONVERT ; DO ACTUAL CONVERSION
 S AICDSWB="",AICDST="SKIP",AICDI=0,AICDLLEN=$L(AICDL)
CHLOOP S AICDI=AICDI+1
 I AICDI>AICDLLEN S AICDEND=1 D:AICDST="SCAN" ENDWORD Q
 S AICDC=$E(AICDL,AICDI)
 S AICDOST=AICDST
 I AICDOST="SKIP",AICDC'?1P S AICDST="SCAN",AICDWS=AICDI
 I AICDOST="SCAN",AICDC?1P,AICDC'="-",AICDC'="'" S AICDEND=0 D ENDWORD S AICDST="SKIP"
 G CHLOOP
ENDWORD S AICDWL=AICDI-AICDWS,AICDWD=$E(AICDL,AICDWS,AICDI-1)
 I AICDWL=1 S AICDSWB=AICDSWB_AICDWD I AICDEND S AICDWD=AICDSWB D STOREWD
 I AICDWL>1 D STOREWD I AICDSWB'="" S AICDWD=AICDSWB,AICDSWB="" D STOREWD
 Q
STOREWD ;
REMQT S AICDJ=$F(AICDWD,"'") I AICDJ>0 S AICDWD=$E(AICDWD,1,AICDJ-2)_$E(AICDWD,AICDJ,255) G REMQT
 I AICDWD'["-" D STOREWD2 Q
 S AICDWD2="" F AICDJ=1:1 S AICDWF=$P(AICDWD,"-",AICDJ) Q:AICDWF=""  Q:$L(AICDWF)>2  S AICDWD2=AICDWD2_AICDWF
 I AICDWF="" S AICDWD=AICDWD2 D STOREWD2 Q
 S AICDWD2=AICDWD F AICDJ=1:1 S AICDWF=$P(AICDWD2,"-",AICDJ) Q:AICDWF=""  S AICDWD=AICDWF D STOREWD2
 Q
STOREWD2 ;
 Q:(AICDWD?1N.E)!(^DD("KWIC")[("^"_AICDWD_"^"))
 Q:$L(AICDWD)=2&("^IN^OF^AN^IS^AS^AT^IF^IT^ON^OR^BY^"[("^"_AICDWD_"^"))
 Q:AICDWD?1N.E
 S AICDWT(AICDWD)=""
 Q