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

AUGC.m

Go to the documentation of this file.
  1. %AUGC ; COPY GLOBAL (ANY LEVEL) [ 12/30/86 9:57 AM ]
  1. NEW
  1. GSGL R !,"Source global: ",SG,!
  1. Q:SG=""
  1. S:$E(SG)'="^" SG="^"_SG
  1. S:SG'["(" SG=SG_"("
  1. S:$E(SG,$L(SG))="," SG=$E(SG,1,$L(SG)-1)
  1. I SG'?1"^"1U.U1"(".UNP W $C(7) G GSGL
  1. I $E(SG,$L(SG))=")" W !!,"Global must be partial!,",!,$C(7) G GSGL
  1. S SUB=$P(SG,"(",2),SCNT=0 F L=0:0 S SCNT=SCNT+1,NSUB=$P(SUB,",",SCNT) Q:NSUB="" Q:NSUB'?1N.N&(NSUB'?1"."1N.N)&(NSUB'?1""""1UN.UN1"""")
  1. I NSUB'="" W !!,"Invalid subscript!",$C(7) G GSGL
  1. K SUB,SCNT,NSUB
  1. I $E(SG,$L(SG))="(" I $D(@($E(SG,1,$L(SG)-1)))=0 W !!,"Global ",SG," does not exist!",!,$C(7) G GSGL
  1. I $E(SG,$L(SG))'="(" I $D(@(SG_")"))=0 W !!,"Partial global ",SG," does not exist!",!,$C(7) G GSGL
  1. GDGL R !,"Destination global: ",DG,!
  1. Q:DG=""
  1. S:$E(DG)'="^" DG="^"_DG
  1. S:DG'["(" DG=DG_"("
  1. S:$E(DG,$L(DG))="," DG=$E(DG,1,$L(DG)-1)
  1. I DG'?1"^"1U.U1"(".UNP W $C(7) G GDGL
  1. I $E(DG,$L(DG))=")" W !!,"Global must be partial!,",!,$C(7) G GDGL
  1. S SUB=$P(DG,"(",2),SCNT=0 F L=0:0 S SCNT=SCNT+1,NSUB=$P(SUB,",",SCNT) Q:NSUB="" Q:NSUB'?1N.N&(NSUB'?1""""1UN.UN1"""")
  1. I NSUB'="" W !!,"Invalid subscript!",$C(7) G GDGL
  1. K SUB,SCNT,NSUB
  1. I SG=DG W !!,"Output same as input!",$C(7),! G GSGL
  1. I $L(DG)>$L(SG) I $E(DG,1,$L(SG))=SG W !!,"Output contained in input!",$C(7),! G GSGL
  1. I $L(DG)<$L(SG) I $E(SG,1,$L(DG))=DG W !!,"Input contained in output!",$C(7),! G GSGL
  1. I $E(DG,$L(DG))="(" I $D(@($P(DG,"(",1)))'=0 W !!,"Destination global """,$P(DG,"(",1),""" already exists!",! S IS=""
  1. I $E(DG,$L(DG))'="(" I $D(@(DG_")"))'=0 W !!,"Partial global ",DG," already exists.",! S IS=""
  1. I $D(IS) W !,"KILL (Y/N) " R ANS Q:$E(ANS)'="Y" K:$E(DG,$L(DG))="(" @($E(DG,1,$L(DG)-1)) K:$E(DG,$L(DG))'="(" @(DG_")")
  1. I $E(SG,$L(SG))="(" S FROM=$E(SG,1,$L(SG)-1)
  1. E S FROM=SG_")"
  1. I $E(DG,$L(DG))="(" S TO=$E(DG,1,$L(SG)-1)
  1. E S TO=DG_")"
  1. S:$D(@(FROM))#10 @(TO)=@(FROM)
  1. S (SCMA,DCMA)="" S:$E(SG,$L(SG))'="(" SCMA="," S:$E(DG,$L(DG))'="(" DCMA=","
  1. D WALK
  1. W !!,"All done!",!
  1. K G GSGL
  1. ;
  1. WALK ; TRAVERSE TREE AT CURRENT SUBSCRIPT LEVEL
  1. NEW (SCMA,DCMA,SG,DG)
  1. S NL="" F L=0:0 S NL=$O(@(SG_SCMA_""""_NL_""")")) Q:NL="" D GOTNODE
  1. Q
  1. ;
  1. GOTNODE ; PROCESS ONE NODE
  1. W "."
  1. S FROM=SG_SCMA_"NL)"
  1. S TO=DG_DCMA_"NL)"
  1. I $D(@(FROM))#10 S VAL=@(FROM),@(TO)=VAL
  1. I $D(@(FROM))\10 S LNL=$L(NL),SG=SG_SCMA_""""_NL_"""",DG=DG_DCMA_""""_NL_"""",SVSCMA=SCMA,SVDCMA=DCMA,(SCMA,DCMA)="," D WALK S SCMA=SVSCMA,DCMA=SVDCMA,SG=$E(SG,1,$L(SG)-(LNL+2+$L(SCMA))),DG=$E(DG,1,$L(DG)-(LNL+2+$L(DCMA)))
  1. Q