source: FOIAVistA/trunk/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQAB-XT-XUC-XUR-ZIN-ZTED/ZINDX9.m@ 811

Last change on this file since 811 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.5 KB
Line 
1%INDX9 ;SF/RWF - %INDEX SYNTAX CHECKER ;8/18/93 12:22 ;
2 ;;7.3;TOOLKIT;;Apr 25, 1995
3 D PARSE S LI=0,AC=255 F %=0:0 S %=$O(LV(%)) Q:%'>0 S LI(%)=0
4 Q
5 ;LV is a set of Linked Values
6PARSE K LV,LI S (ERR,LI,I)=0,(LL,LV)=1,(OP,CH)="",Q="""" ;D NEW S LL(LLO,8)=LL
7 ;
8PA2 S I=I+1,CH=$E(STR,I),CH1=$E(STR,I+1) G:CH="" PEND
9 G E:CH=";"!(CH'?1ANP) I """$()"[CH D QUOTE:CH=Q,FUNC:CH="$",DN:CH="(",UP:CH=")" G PA2
10 I CH="^",I=LL G PA2:CH1'="[" S I=I+1,X=$E(STR,LL,I) D ADD S LL=I+1 G PA2
11 I CH?1A!(CH="%") D VAR G PA2
12 I CH?1N D NUM G PA2
13 S:"+-#'/*&![]<>?"[CH OP=CH I CH="?",",!"'[$E(STR,I-1) D AR,PAT G PA2
14 I CH?1P D AR,E^%INDX1(21):(CH_CH1=",,")
15 G PA2
16 ;
17DN D STR S X=CH D ADD,NEW S LI(LV)=LI,LV=LV+1 S:'$D(LI(LV)) LI(LV)=0 S LI=LI(LV),LI(LV-1,1)=LI
18 Q
19UP I LV<2 D E^%INDX1(5) Q
20 D STR S EC=LI-LI(LV-1,1),X=$C(10) D ADD,NEW S LI(LV)=LI,LV=LV-1,LI=LI(LV)
21 S X=EC D ADD S X=CH D ADD I CH1]"",CH1'?1P D E^%INDX1(46)
22 Q
23NEW S LL=I+1
24 Q
25AR D STR S X=CH D ADD,NEW Q
26STR S X=$E(STR,LL,I-1) Q:'$L(X) ;Drop into ADD
27ADD S LI=LI+1,LV(LV,LI)=X Q
28 Q
29QUOTE F I=I+1:1 S CH=$E(STR,I) Q:CH=""!(CH=Q)
30 I $E(STR,I+1)=Q S I=I+1 G QUOTE
31 I OP'="?",$E(STR,I+1)]"","[]()<>\/+-=&!_#*,:'"'[$E(STR,I+1) S ERR=46 G ^%INDX1
32 Q:CH]"" S ERR=6 D ^%INDX1 Q
33VAR F J=I+1:1 S CH=$E(STR,J) Q:CH'?1AN
34 S I=J-1 Q
35NUM F J=I+1:1 S CH=$E(STR,J) Q:"0123456789."'[CH!(CH="")
36 I CH="E" S CH=$E(STR,J+1) I CH?1N!("+-"[CH) S I=J G NUM
37 I CH]"",CH'?1P S ERR=53 D ^%INDX1
38 S I=J-1 Q
39INC S I=I+1,CH=$E(STR,I)
40 Q
41FUNC D INC S X=CH D VAR S S=$E(STR,LL,I),LL=I+1 G EXT:S["$$" G SPV:CH'="("
42 S S=$E(S,2,9),F1=$F("ACDEFGJLNOPQRSTVZ",X),ERR=3 G:F1'>1 ^%INDX1 S F1=$P($T(FNC),",",F1)
43 S:$E(S,1,2)="TR" F1="TRANSLATE^2;3" S:$E(S,1,2)="FN" F1="FNUMBER^2;3"
44 I "ZV"[X S ERR=$S("Z"[X:31,1:27) D ^%INDX1
45 I $L(S)>1,X'["Z",$P(F1,S)]"" S ERR=3 D ^%INDX1
46 S X="$"_F1,CH="" D ADD Q
47SPV S X=S D ADD S CH=$E(S,2) I "HIJSTXYZ"'[CH S ERR=4 G ^%INDX1
48 I CH="Z" S ERR=28 G ^%INDX1
49 I $L(S)>2,",$HOROLOG,$IO,$STORAGE,$TEST,$X,$Y,"'[(","_S_",") S ERR=4 G ^%INDX1
50EXT ;EXTRINSIC
51 S X=S,CH="" D ADD Q
52E S ERR=11 D ^%INDX1 Q ;
53PAT F I=I+1:1 S CH=$E(STR,I) D PATQ:CH=Q I CH=""!(CH'?1N&("ACELNPU."'[CH)) Q
54 S I=I-1 I ":),@+-_*/\!&'"'[CH D E^%INDX1(16),SEP Q
55 Q
56PATQ F I=I+1:1 S CH=$E(STR,I) Q:CH=""!(CH=Q)
57 S ERR=6,I=I+1,CH=$E(STR,I) D:$E(STR,I-1)="" ^%INDX1 G:CH=Q PATQ Q
58PEND D AR,E^%INDX1(5):LV>1,E^%INDX1(21):($G(LV(1,1))=",") ;LV>1 means mis-match ()
59 Q
60SEP ;Find sep
61 Q
62FNC ;;,ASCII^1;2,CHAR^1;999,DATA^1;1,EXTRACT^1;3,FIND^2;3,GET^1;1,JUSTIFY^2;3,LENGTH^1;2,NEXT^1;1,ORDER^1;1,PIECE^2;4,QUERY^1;1,RANDOM^1;1,SELECT^1;999,TEXT^1;1,VIEW^1;999,
63TEST S STR="@^(0)" D %INDX9
Note: See TracBrowser for help on using the repository browser.