135 lines
5.5 KiB
Mathematica
135 lines
5.5 KiB
Mathematica
|
LEXXFI2 ; ISL/KER - File Info - Checksums ; 07/28/2004
|
||
|
;;2.0;LEXICON UTILITY;**32**;Sep 23, 1996
|
||
|
Q
|
||
|
;
|
||
|
; Global Variables
|
||
|
; None
|
||
|
;
|
||
|
; External References
|
||
|
; None
|
||
|
;
|
||
|
Q
|
||
|
ONE(X) ; Checksum for ONE file
|
||
|
N LEXENV S LEXENV=$$ENV^LEXXFI Q:+LEXENV'>0
|
||
|
N LEXFI,LEXFC,LEXMOD,LEXMUL,LEXNM,LEXTXT,LEXTT,LEXLDR,LEXTND
|
||
|
N LEXTSND,LEXTCS,LEXTSCS,LEXEX,LEXLINE,LEXCTLC
|
||
|
S (LEXTND,LEXTSND,LEXTCS,LEXTSCS,LEXMOD,LEXMUL)=0,LEXFI=$G(X) Q:+LEXFI'>0
|
||
|
S LEXLDR=$$LDR^LEXXFI8(LEXFI),LEXMOD=LEXMOD+($$MOD^LEXXFI8(LEXFI))
|
||
|
S LEXNM=$$FN^LEXXFI8(LEXFI),LEXTT=" "
|
||
|
D TT^LEXXFI8(LEXFI,"Checksum"),BL^LEXXFI8
|
||
|
D CS,CTLD,MF^LEXXFI8(LEXMOD),CTLD
|
||
|
Q
|
||
|
ALL ; Checksum for ALL files
|
||
|
N LEXENV S LEXENV=$$ENV^LEXXFI Q:+LEXENV'>0
|
||
|
N LEXA,LEXCTR,LEXD,LEXEX,LEXF,LEXFC,LEXFI,LEXI,LEXLDR,LEXMOD,LEXMUL
|
||
|
N LEXN,LEXND,LEXP,LEXRTN,LEXT,LEXTAG,LEXTND,LEXTSND,LEXTCS,LEXTSCS,LEXU
|
||
|
S LEXMUL=1,(LEXTND,LEXTSND,LEXTCS,LEXTSCS,LEXMOD,LEXFC)=0
|
||
|
D TT^LEXXFI8("","Checksums"),BL^LEXXFI8
|
||
|
S LEXFI="",LEXTAG="FILES",LEXRTN="LEXXFI",LEXCTR=0
|
||
|
F D Q:LEXFI=""
|
||
|
. S LEXCTR=LEXCTR+1,LEXEX="S LEXLINE=$T("_LEXTAG_"+"_LEXCTR_"^"_LEXRTN_")"
|
||
|
. X LEXEX S LEXFI=$P(LEXLINE,";;",2,3) Q:'$L(LEXFI)
|
||
|
. S LEXLDR=$P(LEXFI,";;",1),LEXFI=$P(LEXFI,";;",2) Q:'$L(LEXFI)
|
||
|
. S LEXLDR=$S(+LEXLDR>0:" * ",1:" ")
|
||
|
. S:LEXLDR["*" LEXMOD=+($G(LEXMOD))+1 D CS
|
||
|
I +LEXTND>0 D
|
||
|
. I +($G(LEXTCS))>0,+($G(LEXTSCS))>0,+($G(LEXTND))>0,+($G(LEXTSND))>0 D
|
||
|
. . Q:+LEXTSND>LEXTND Q:+LEXTSCS>LEXTCS
|
||
|
. . D BL^LEXXFI8,TL^LEXXFI8(" Totals"),TL^LEXXFI8(" ------")
|
||
|
. . D TL^LEXXFI8($$FMT(" ","Static Files",LEXTSND,LEXTSCS))
|
||
|
. . D TL^LEXXFI8($$FMT(" * ","Variable Files",(LEXTND-LEXTSND),(LEXTCS-LEXTSCS)))
|
||
|
. . D TL^LEXXFI8($$FMT(" ","All Files",LEXTND,LEXTCS))
|
||
|
D MF^LEXXFI8(LEXMOD),CTLD
|
||
|
Q
|
||
|
CS ; Checksum for File X
|
||
|
N LEXCS,LEXND,LEX S LEXFI=+($G(LEXFI)) Q:+LEXFI'>0
|
||
|
D DDI^LEXXFI6(+LEXFI,.LEX) Q:'$D(LEX("DIC",LEXFI,0,"GL")) Q:+LEXFI=757.09
|
||
|
S LEXLDR=$G(LEXLDR),LEXCS=$$CHECKSUM(LEXFI,.LEX),LEXND=+($P(LEXCS,"^",2)),LEXCS=+($P(LEXCS,"^",1))
|
||
|
S LEXTND=+($G(LEXTND))+LEXND,LEXTCS=+($G(LEXTCS))+LEXCS,LEXFC=+($G(LEXFC))+1
|
||
|
S:$G(LEXLDR)'["*" LEXTSCS=+($G(LEXTSCS))+LEXCS,LEXTSND=+($G(LEXTSND))+LEXND
|
||
|
D:LEXFC=1 TL^LEXXFI8($$FMT(" ","File #","Nodes",$S(+LEXMUL>0:"Checksums",1:"Checksum")))
|
||
|
D:LEXFC=1 TL^LEXXFI8($$FMT(" ","------------","----------","---------------"))
|
||
|
D TL^LEXXFI8($$FMT(LEXLDR,LEXFI,LEXND,LEXCS))
|
||
|
Q
|
||
|
FMT(X,LEXFI,LEXND,LEXCS) ; Format Line
|
||
|
N LEXT S LEXT=$G(X)_$G(LEXFI) S LEXT=LEXT_$J("",(18-$L(LEXT)))_$J($G(LEXND),10)
|
||
|
S X=LEXT_$J("",(31-$L(LEXT)))_$J($G(LEXCS),15)
|
||
|
Q X
|
||
|
CHECKSUM(X,LEX) ; Return CHECKSUM^NODES
|
||
|
N DIC,LEXC,LEXCNT,LEXCTR,LEXD,LEXE,LEXFI,LEXGCS,LEXN,LEXP,LEXRT,LEXT
|
||
|
N LEXTYP,LEXID,LEXRC,LEXIC,LEXCTL
|
||
|
S (LEXRC,LEXIC)=0
|
||
|
S LEXFI=+($G(X)) Q:+LEXFI'>0 "0^0" Q:'$D(LEX("DIC",LEXFI,0,"GL")) "0^0"
|
||
|
S DIC=$G(LEX("DIC",LEXFI,0,"GL")) Q:'$L(DIC) "0^0"
|
||
|
S LEXRT=$S(DIC[",":($E(DIC,1,($L(DIC)-1))_")"),1:$E(DIC,1,($L(DIC)-1))),LEXC=DIC
|
||
|
S LEXN=LEXRT,(LEXCNT,LEXCTR,LEXGCS)=0
|
||
|
F S LEXN=$Q(@LEXN) Q:LEXN=""!(LEXN'[LEXC) D
|
||
|
. S LEXCTR=LEXCTR+1,LEXD=@LEXN
|
||
|
. S LEXT=LEXN_"="_LEXD,LEXE=$L(LEXT)
|
||
|
. S LEXID=$P(LEXN,DIC,2,200)
|
||
|
. S:LEXID["," LEXID=$P(LEXID,",",1)
|
||
|
. S:LEXID[")" LEXID=$P(LEXID,")",1)
|
||
|
. S LEXTYP="UNK" S:+LEXID=LEXID LEXTYP="REC"
|
||
|
. S:+LEXID'=LEXID LEXTYP="IDX"
|
||
|
. S LEXCTL=$$CTL(LEXT) I +LEXCTL>0 D
|
||
|
. . Q:LEXTYP="UNK" N LEXTOT S LEXTOT=0
|
||
|
. . S:LEXTYP="REC" (LEXTOT,LEXRC)=LEXRC+LEXCTL
|
||
|
. . S:LEXTYP="IDX" (LEXTOT,LEXIC)=LEXIC+LEXCTL
|
||
|
. . S $P(LEXCTLC(+LEXFI,LEXTYP),"^",1)=$P($G(LEXCTLC(+LEXFI,LEXTYP)),"^",1)+1
|
||
|
. . S $P(LEXCTLC(+LEXFI,LEXTYP),"^",2)=LEXTOT
|
||
|
. ;
|
||
|
. F LEXP=1:1:LEXE S LEXGCS=$A(LEXT,LEXP)*LEXP+LEXGCS
|
||
|
S X=LEXGCS_"^"_LEXCTR D CTLC
|
||
|
Q X
|
||
|
CTLD ; Control Characters (Display)
|
||
|
Q:$G(LEXCTLC(0))'>0
|
||
|
N LEXFI,LEXFIN,LEXFINC,LEXFII,LEXFIIC,LEXLN,LEXTH,LEXT1,LEXT2
|
||
|
S (LEXFI,LEXFIN,LEXFINC,LEXFII,LEXFIIC,LEXLN)=0
|
||
|
F S LEXFI=$O(LEXCTLC(LEXFI)) Q:+LEXFI=0 D
|
||
|
. S LEXFIN=$G(LEXCTLC(LEXFI,"REC"))
|
||
|
. S LEXFINC=$P(LEXFIN,"^",2),LEXFIN=$P(LEXFIN,"^",1)
|
||
|
. S LEXFII=$G(LEXCTLC(LEXFI,"IDX"))
|
||
|
. S LEXFIIC=$P(LEXFII,"^",2),LEXFII=$P(LEXFII,"^",1)
|
||
|
. S LEXTH=$$FN^LEXXFI8(LEXFI) Q:'$L(LEXTH)
|
||
|
. S LEXTH=" "_LEXTH_" file #"_LEXFI S (LEXT1,LEXT2)=""
|
||
|
. I LEXFIN>0,LEXFINC>0 D
|
||
|
. . S LEXT1=" "_$J(LEXFIN,4)_" Data Record"_$S(LEXFIN>0:"s",1:"")_" with "_LEXFINC_" control character"_$S(LEXFINC>0:"s",1:"")
|
||
|
. I LEXFII>0,LEXFIIC>0 D
|
||
|
. . S LEXT2=" "_$J(LEXFII,4)_" Cross-Reference entr"_$S(LEXFII>0:"ies",1:"y")_" with "_LEXFIIC_" control character"_$S(LEXFIIC>0:"s",1:"")
|
||
|
. Q:'$L(LEXT1)&('$L(LEXT2))
|
||
|
. S LEXLN=LEXLN+1 I LEXLN=1 D
|
||
|
. . D BL^LEXXFI8,TL^LEXXFI8(" Control Character(s) Found")
|
||
|
. . D TL^LEXXFI8(" =========================="),BL^LEXXFI8
|
||
|
. D TL^LEXXFI8(LEXTH)
|
||
|
. D:$L(LEXT1) TL^LEXXFI8(LEXT1)
|
||
|
. D:$L(LEXT2) TL^LEXXFI8(LEXT2)
|
||
|
Q
|
||
|
CTL(X) ; Control Characters
|
||
|
N TXT S TXT=$G(X)
|
||
|
N I,CHR S X=0 F I=1:1 S CHR=$E($G(TXT),I) Q:'$L(CHR) D
|
||
|
. I $A(CHR)<32!($A(CHR)>126) S X=X+1
|
||
|
Q X
|
||
|
CTLC ; Control Character Array
|
||
|
N LEXFI,LEXND,LEXCC,LEXFIC,LEXNDC,LEXCCC
|
||
|
S (LEXFI,LEXND,LEXCC,LEXFIC,LEXNDC,LEXCCC)=0
|
||
|
F S LEXFI=$O(LEXCTLC(LEXFI)) Q:+LEXFI=0 D
|
||
|
. S LEXFIC=LEXFIC+1,(LEXNDC,LEXCCC)=0
|
||
|
. S LEXND=$P($G(LEXCTLC(LEXFI,"REC")),"^",1)
|
||
|
. S LEXCC=$P($G(LEXCTLC(LEXFI,"REC")),"^",2)
|
||
|
. S LEXNDC=LEXNDC+LEXND,LEXCCC=LEXCCC+LEXCC
|
||
|
. S LEXND=$P($G(LEXCTLC(LEXFI,"IDX")),"^",1)
|
||
|
. S LEXCC=$P($G(LEXCTLC(LEXFI,"IDX")),"^",2)
|
||
|
. S LEXNDC=LEXNDC+LEXND,LEXCCC=LEXCCC+LEXCC
|
||
|
. S LEXCTLC(LEXFI,0)=LEXNDC_"^"_LEXCCC
|
||
|
. S LEXCTLC(0)=LEXFIC
|
||
|
Q
|
||
|
TT ;
|
||
|
S LEXCTLC(0)=1
|
||
|
S LEXCTLC(80,0)="43^43"
|
||
|
S LEXCTLC(80,"IDX")="12^14"
|
||
|
S LEXCTLC(80,"REC")="8^10"
|
||
|
S LEXCTLC(81,0)="43^43"
|
||
|
S LEXCTLC(81,"IDX")="20^28"
|
||
|
S LEXCTLC(81,"REC")="23^26"
|
||
|
Q
|