[613] | 1 | XTLKWIC ;IHS/OHPRD/ACC,ALB/JLU,SFISC/JC - KWIC ROUTINE FOR FILE MANAGER ;07/22/93 15:52
|
---|
| 2 | ;;7.3;TOOLKIT;;Apr 25, 1995
|
---|
| 3 | S N SWB,OSTATE,STATE,LLEN,C,D,I,J,WF,WS,WD,WD2,WL,END,Q
|
---|
| 4 | S D=%,L=$S($D(JLX):JLX,1:X) K JLX
|
---|
| 5 | D TOKENIZE S I="" F J=0:0 S I=$O(WT(I)) Q:I="" I ^DD("KWIC")'[("^"_I_"^") S @D=""
|
---|
| 6 | G QUIT
|
---|
| 7 | K N SWB,OSTATE,STATE,LLEN,C,D,I,J,WF,WS,WD,WD2,WL,END,Q
|
---|
| 8 | S D=%,L=$S($D(JLX):JLX,1:X) K JLX
|
---|
| 9 | D TOKENIZE S I="" F J=0:0 S I=$O(WT(I)) Q:I="" I ^DD("KWIC")'[("^"_I_"^") K:'($D(@D)\10) @D
|
---|
| 10 | QUIT K WT,I,J Q
|
---|
| 11 | TOKENIZE ; CONVERT INPUT LINE TO TOKENS ; [ 03/20/86 12:44 PM ]
|
---|
| 12 | K WT
|
---|
| 13 | D CONVERT
|
---|
| 14 | K SWB,OSTATE,STATE,LLEN,C,I,J,WF,WS,WD,WD2,WL,END,Q
|
---|
| 15 | Q
|
---|
| 16 | ;
|
---|
| 17 | CONVERT ; DO ACTUAL CONVERSION
|
---|
| 18 | S SWB="",STATE="SKIP",I=0,LLEN=$L(L)
|
---|
| 19 | CHLOOP S I=I+1
|
---|
| 20 | I I>LLEN S END=1 D:STATE="SCAN" ENDWORD Q
|
---|
| 21 | S C=$E(L,I)
|
---|
| 22 | S OSTATE=STATE
|
---|
| 23 | I OSTATE="SKIP",C'?1P S STATE="SCAN",WS=I
|
---|
| 24 | I OSTATE="SCAN",C?1P,C'="-",C'="'" S END=0 D ENDWORD S STATE="SKIP"
|
---|
| 25 | G CHLOOP
|
---|
| 26 | ENDWORD S WL=I-WS,WD=$E(L,WS,I-1)
|
---|
| 27 | I WL=1 S SWB=SWB_WD I END S WD=SWB D STOREWD
|
---|
| 28 | I WL>1 D STOREWD I SWB'="" S WD=SWB,SWB="" D STOREWD
|
---|
| 29 | Q
|
---|
| 30 | STOREWD ;
|
---|
| 31 | REMQT S J=$F(WD,"'") I J>0 S WD=$E(WD,1,J-2)_$E(WD,J,255) G REMQT
|
---|
| 32 | I WD'["-" D STOREWD2 Q
|
---|
| 33 | S WD2="" F J=1:1 S WF=$P(WD,"-",J) Q:WF="" Q:$L(WF)>2 S WD2=WD2_WF
|
---|
| 34 | I WF="" S WD=WD2 D STOREWD2 Q
|
---|
| 35 | S WD2=WD F J=1:1 S WF=$P(WD2,"-",J) Q:WF="" S WD=WF D STOREWD2
|
---|
| 36 | Q
|
---|
| 37 | STOREWD2 ;
|
---|
| 38 | Q:(WD?1N.E)!(^DD("KWIC")[("^"_WD_"^"))
|
---|
| 39 | Q:$L(WD)=2&("^IN^OF^AN^IS^AS^AT^IF^IT^ON^OR^BY^"[("^"_WD_"^"))
|
---|
| 40 | Q:WD?1N.E
|
---|
| 41 | S WT(WD)=""
|
---|
| 42 | Q
|
---|