source: WorldVistAEHR/trunk/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQAB-XT-XUC-XUR-ZIN-ZTED/XINDX2.m@ 1500

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

initial load of WorldVistAEHR

File size: 3.7 KB
Line 
1XINDX2 ;ISC/REL,GRK,RWF - PROCESS "GRB" ;04/26/2000 10:44
2 ;;7.3;TOOLKIT;**20,27,48**;Apr 25, 1995
3% S LINE=GRB,COM="" F I=0:0 S STR=$P(LINE,$C(9),1),LINE=$P(LINE,$C(9),2,999),NOA=0 D:STR]"" ARGG Q:LINE']""
4 Q
5 ;Process argument
6ARGG D ^XINDX9 S I=0,AC=999 F %=0:0 S %=$O(LV(%)) Q:%'>0 S I(%)=0
7ARGS ;Proccess all agruments at this level
8 S AC=LI+AC F Q:AC'>LI D INC Q:S="" D ARG
9 Q
10 ;
11ARG ;Process one argument
12 I CH="," D PEEK,E^XINDX1(21):(","[Y)&($$FNC()'="$$") Q
13 Q:CH=Q
14 I (CH?1A)!(CH="%") D LOC Q
15 I CH="^" S LOC="G" G NAK:S="^",EXTGLO:S["[",EXTGLO:S["|",GLO Q
16 I CH="$" D FUN Q
17 I CH="?" D PAT Q
18 I CH="(" D INC S NOA=S D DN,INC Q
19 Q
20 ;
21NAK S LOC="N" G GLO
22EXTGLO D E^XINDX1(50),EG,INC S S=U_S G GLO
23EG N GK,LOC S GK="",LOC="L" ;HANDLE EXTENDED GLOBAL
24 F D INC Q:"]"[CH Q:"|"[CH D ARG
25 Q
26GLO S X=$E(S,2,99) I X]"",S'["^$",X'?1(1U,1"%").7UN D E^XINDX1(12)
27 I GK["*",$E(S,1,2)["^%" D E^XINDX1(45)
28 I S1="(" S S=S_S1 D PEEKDN S:(Y?1N.NP)!($A(Y)=34)!("^$J^$I^$H^"[(U_Y)) S=S_Y
29 D ST(LOC,S) I S1="(" D INC2 S NOA=S D DN,INC
30 Q
31LOC S LOC="L" ;Check variables at end I S'?1.8UN,S'?1"%".7UN,S'?1.8LN,S'?1"%".7LN D E^XINDX1(11)
32 I S1="(" S S=S_S1 D PEEKDN S:(Y?1.N)!($A(Y)=34) S=S_Y
33 D ST(LOC,S) I S1="(" D INC2 S NOA=S D DN,INC
34 Q
35PEEK S Y=$G(LV(LV,LI+1)) Q
36INC2 S LI=LI+1 ;Drop into INC
37INC S LI=LI+1,S=$G(LV(LV,LI)),S1=$G(LV(LV,LI+1)),CH=$E(S) G:$A(S)=10 ERR Q
38DN S LI(LV)=LI,LI(LV,1)=AC,LV=LV+1,LI=LI(LV),AC=NOA
39 D ARGS,UP Q
40UP ;Inc LI as we save to skip the $C(10).
41 D PEEK D:$A(Y)'=10 ERR S LI(LV)=LI+1,LV=LV-1,LI=LI(LV),AC=LI(LV,1) Q
42PEEKDN S Y=$G(LV(LV+1,LI(LV+1)+1)) Q
43ERR D E^XINDX1(43) S (S,S1,CH)="" Q
44 S Z=$P(LV(LV+1),$C(9),LI(LV+1),99),Z=$P(Z,$C(10)) W !,"COUNT=",$L(Z,",")
45 ;functions
46FUN N FUN S FUN=S G EXT:S["$$",PKG:S["$&",SPV:S1'["(" S NOA=$P(S,"^",2)
47 D INC2 I S'>0 D E^XINDX1(43) ;Sit on NOA
48 G:FUN["$TE" TEXT
49 S Y=1 F Z1=LI(LV+1)+1:1 S X=$G(LV(LV+1,Z1)) Q:$A(X)=10!(X="") S:X="," Y=Y+1
50 I NOA,Y<NOA!(Y>$P(NOA,";",2)) D E^XINDX1(43)
51 S NOA=S D DN,INC Q
52 ;
53TEXT S Y=$$ASM^XINDX3(LV+1,LI(LV+1)+1,$C(10)) D ST("MK","$T("_$S($E(Y)'="+":Y,1:""))
54 I $$VT(Y) D ST("I",Y)
55 I Y["^",$$VT($P(Y,"^",2)) N X1,X2 S X1=$P(Y,"^"),X2=$P(Y,"^",2) D ST("X",X2_$S($$VT(X1):" "_X1,1:""))
56 D FLUSH(LV+1) Q
57 ;special variables
58SPV ;
59 I "^$D^$EC^$ES^$ET^$I^$K^$P^$Q^$ST^$SY^"[("^"_X_"^") D ST("MK",X)
60 Q
61EXT ;Extrinsic functions
62 I $E(S1)="^" S Y=$E(S1,2,99)_" "_S D INC S S=Y ;Build S and fall thru
63 D ST($S(S[" ":"X",1:"I"),S) ;Internal, eXternal
64 I S1["(" D INC2 S NOA=S D DN,INC ;Process param.
65 Q
66PKG ;Exteran Package
67 D ST("X",S) ;Record Exteral name
68 I S1["(" D INC2 S NOA=S D DN,INC ;Process param.
69 Q
70PAT D INC I $E(S)="@" D INC,ARG Q
71 F D REPCNT,PATCODE Q:$E(S)=""
72 Q
73REPCNT F I=1:1 Q:("0123456789."'[$E(S,I))!($E(S,I)="")
74 S X=$E(S,1,I-1),S=$E(S,I,999) I ('$L(X))!($L(X,".")>2) S S="" D E^XINDX1(16)
75 Q
76PATCODE I $E(S)=Q S I=1 D PATQ S S=$E(S,I,999) S:$L(CH)&(",)"[CH) S=$E(S,2,999) Q
77 F I=1:1 Q:("ACELNPUacelnpu()"'[$E(S,I))!($E(S,I)="")
78 S X=$E(S,1,I-1),S=$E(S,I,999) I I=1 S S="" D E^XINDX1(16)
79 I $E(S)="," S S=$E(S,2,999) ;Pull ',' out of alternation
80 Q
81PATQ F I=I+1:1 S CH=$E(S,I) Q:CH=""!(CH=Q)
82 S I=I+1 D:CH="" E^XINDX1(6) S CH=$E(S,I) G:CH=Q PATQ
83 Q
84 ;
85ST(LOC,S) S:'$D(V(LOC,S)) V(LOC,S)="" I $D(GK),GK]"",V(LOC,S)'[GK S V(LOC,S)=V(LOC,S)_GK
86 S GK="" Q
87VT(X) ;Check if a valid name
88 Q (X?1U.7UN)!(X?1"%".7UN)!(X?1.8N)
89FLUSH(L) ;Flush rest of list with this offset
90 N I,CH S I=LI(L)+1 F I=I:1 S CH=$G(LV(L,I)) Q:$C(10)[CH D:CH="(" FLUSH(L+1)
91 S LI(L)=I Q
92 ;
93FNC(NEW) ;Sets or returns the current function
94 I $D(NEW) S LV(LV+1,"FNC",LI)=NEW Q
95 N W S W=+$S($D(LV(LV,"FNC",LI)):LI,1:$O(LV(LV,"FNC",LI),-1))
96 Q $G(LV(LV,"FNC",W))
97 ;
98OP(NEW) ;Sets or returns the current operator
99 I $D(NEW) S LV(LV,"OP",LI)=NEW Q
100 N W S W=+$S($D(LV(LV,"OP",LI)):LI,1:$O(LV(LV,"OP",LI),-1))
101 Q $G(LV(LV,"OP",W))
102 ;
Note: See TracBrowser for help on using the repository browser.