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

ZZRCSUM.m

Go to the documentation of this file.
  1. ZZRCSUM ;EIE/HSED/mw - adhoc routine checksum comparison utility; 08/13/09
  1. ;;1.5;EIE/HSED Research Utility; August 04, 2009
  1. ;
  1. ; menu...
  1. F D Q:$D(DIRUT)
  1. .W !!,"Routine Set Checksum Comparison Utility"
  1. .W !,"This configuration is: ",$P($ZU(86),"*",2)
  1. .W !,"This UCI is : ",$ZU(5)
  1. .S DIR(0)="NAO^1:4"
  1. .S DIR("A")="Select OPTION NUMBER: "
  1. .S DIR("A",1)=" [1] Build Master Routine Set"
  1. .S DIR("A",2)=" [2] Build Comparison Routine Set"
  1. .S DIR("A",3)=" [3] Report Comparison Results"
  1. .S DIR("A",4)=" [4] Exit"
  1. .S DIR("A",5)=" "
  1. .S DIR("?")="^D HELP^ZZRCSUM"
  1. .W !
  1. .D ^DIR K DIR Q:$D(DIRUT)
  1. .I Y=4 S DIRUT=1 Q
  1. .S ZZOPT=Y
  1. .I ZZOPT=1 D GETBASE
  1. .I ZZOPT=2 D GETCOMP
  1. .I ZZOPT=3 D REPORT
  1. .K ZZOPT
  1. K DIRUT,DTOUT,X,Y,ZZOPT
  1. Q
  1. ;
  1. GETBASE ; collect master routine set...
  1. N DIRUT,DTOUT,X,Y
  1. I $D(^XTMP("HSED","MASTER_RSET")) D I $D(DIRUT) Q
  1. .W !!,"CAUTION!"
  1. .W !,"The baseline routine set global appears to be already"
  1. .W !,"set in this UCI. If you continue, I will delete the"
  1. .W !,"existing baseline routine set global."
  1. .S DIR(0)="YA"
  1. .S DIR("A")="Are you sure you wish to continue (Y/N)? "
  1. .W !
  1. .D ^DIR K DIR Q:$D(DIRUT)
  1. .I Y=0 D Q
  1. ..W !,"build of master routine set aborted"
  1. ..S DIRUT=1
  1. ; okay to continue...
  1. W !!,"Step 1: Initial routine selection"
  1. X ^%ZOSF("RSEL")
  1. I +$G(^UTILITY($J,0))=0 W !!,"No routines were found in this UCI!" Q
  1. ;
  1. ; move routine set to ^XTMP("HSED","MASTER_RSET",...), screening out Cache
  1. ; routines beginning with "%SYS."...
  1. I $G(^XTMP("HSED",0))="" S ^XTMP("HSED",0)="3100101^3100101^HSED Research Utility"
  1. K ^XTMP("HSED","MASTER_RSET")
  1. ; set initial routine count...
  1. S ^XTMP("HSED","MASTER_RSET",0)=+$G(^UTILITY($J,0))
  1. W !!,"Step 2: Create master routine set"
  1. W !,"Creating master routine set in ^XTMP(""HSED"",""MASTER_RSET"")."
  1. W !,"Note: screening out %SYS.* routines, and verifying routines in the"
  1. W !," initial selection list actually exist in this UCI. The routine"
  1. W !," count after this procedure may be different than reported above."
  1. S ROU="",RCT=+$G(^XTMP("HSED","MASTER_RSET",0))
  1. F S ROU=$O(^UTILITY($J,ROU)) Q:ROU="" D
  1. .I $E(ROU,1.5)="%SYS." S RCT=RCT-1 Q
  1. .S X=ROU
  1. .X ^%ZOSF("TEST")
  1. .I '$T S RCT=RCT-1 Q
  1. .S ^XTMP("HSED","MASTER_RSET",ROU)=""
  1. W !,"After screening and verifying, routine count = ",RCT
  1. S ^XTMP("HSED","MASTER_RSET",0)=RCT
  1. K RCT,ROU,^UTILITY($J)
  1. W !!,"Step 3: Compute checksums"
  1. W !,"Computing checksums for ",+$G(^XTMP("HSED","MASTER_RSET",0))," routines",!
  1. D CHKSUM("MASTER_RSET")
  1. W !,"All done."
  1. Q
  1. ;
  1. GETCOMP ; collect comparison routine set...
  1. N DIRUT,DTOUT,X,Y
  1. I $D(^XTMP("HSED","COMPARE_RSET")) D I $D(DIRUT) Q
  1. .W !!,"CAUTION!"
  1. .W !,"The comparison routine set global appears to be already"
  1. .W !,"set in this UCI. If you continue, I will delete the"
  1. .W !,"existing comparison routine set global."
  1. .S DIR(0)="YA"
  1. .S DIR("A")="Are you sure you wish to continue (Y/N)? "
  1. .W !
  1. .D ^DIR K DIR Q:$D(DIRUT)
  1. .I Y=0 D Q
  1. ..W !,"build of comparison routine set aborted"
  1. ..S DIRUT=1
  1. ; okay to continue...
  1. W !!,"Step 1: Initial routine selection"
  1. X ^%ZOSF("RSEL")
  1. I +$G(^UTILITY($J,0))=0 W !!,"No routines were found in this UCI!" Q
  1. ;
  1. ; move routine set to ^XTMP("HSED","COMPARE_RSET",...), screening out Cache
  1. ; routines beginning with "%SYS."...
  1. I $G(^XTMP("HSED",0))="" S ^XTMP("HSED",0)="3100101^3100101^HSED Research Utility"
  1. K ^XTMP("HSED","COMPARE_RSET")
  1. ; set initial routine count...
  1. S ^XTMP("HSED","COMPARE_RSET",0)=+$G(^UTILITY($J,0))
  1. W !!,"Step 2: Create comparison routine set"
  1. W !,"Creating comparison routine set in ^XTMP(""HSED"",""COMPARE_RSET"")."
  1. W !,"Note: screening out %SYS.* routines, and verifying routines in the"
  1. W !," initial selection list actually exist in this UCI. The routine"
  1. W !," count after this procedure may be different than reported above."
  1. S ROU="",RCT=+$G(^XTMP("HSED","COMPARE_RSET",0))
  1. F S ROU=$O(^UTILITY($J,ROU)) Q:ROU="" D
  1. .I $E(ROU,1.5)="%SYS." S RCT=RCT-1 Q
  1. .S X=ROU
  1. .X ^%ZOSF("TEST")
  1. .I '$T S RCT=RCT-1 Q
  1. .S ^XTMP("HSED","COMPARE_RSET",ROU)=""
  1. W !,"After screening and verifying, routine count = ",RCT
  1. S ^XTMP("HSED","COMPARE_RSET",0)=RCT
  1. K RCT,ROU,^UTILITY($J)
  1. W !!,"Step 3: Compute checksums"
  1. W !,"Computing checksums for ",+$G(^XTMP("HSED","COMPARE_RSET",0))," routines",!
  1. D CHKSUM("COMPARE_RSET")
  1. W !,"All done."
  1. Q
  1. ;
  1. REPORT ; report comparison results...
  1. W !!,"Routine Set Checksum Comparison -- Results"
  1. N CCT,MCT,NIMCT,RCT
  1. S CCT=+$G(^XTMP("HSED","COMPARE_RSET",0))
  1. S MCT=+$G(^XTMP("HSED","MASTER_RSET",0))
  1. W !!,"Routine count in MASTER = ",$J(MCT,10)
  1. W !,"Routine count in COMPARE = ",$J(CCT,10)
  1. W !,"Difference = ",$J($$DIFF(MCT,CCT),10)
  1. ;
  1. ; first pass -- use "MASTER_RSET" and check to see that all routines
  1. ; in the master are present in the compare...
  1. W !!,"Verifying all MASTER SET routines are present in COMPARE SET."
  1. W !,"Routines listed below are in the MASTER SET, but NOT in the"
  1. W !,"COMPARE SET...",!
  1. S ROU=" ",RCT=0
  1. F S ROU=$O(^XTMP("HSED","MASTER_RSET",ROU)) Q:ROU="" D
  1. .I $D(^XTMP("HSED","COMPARE_RSET",ROU)) Q
  1. .W ROU,?$X+(10-$L(ROU))
  1. .I $X>70 W !
  1. .S RCT=RCT+1
  1. W !!,RCT," routine",$S(RCT=0:"s",RCT>1:"s",1:"")," in the MASTER SET were NOT found in the COMPARE SET."
  1. K RCT,ROU
  1. ;
  1. W !!,"Comparing checksums: COMPARE SET to MASTER SET..."
  1. S ROU=" ",(NIMCT,RCT)=0
  1. F S ROU=$O(^XTMP("HSED","COMPARE_RSET",ROU)) Q:ROU="" D
  1. .I '$D(^XTMP("HSED","MASTER_RSET",ROU)) D Q
  1. ..;W !,ROU,?12,"--",?24,"not in MASTER SET"
  1. ..S NIMCT=NIMCT+1
  1. .S CVAL=^XTMP("HSED","COMPARE_RSET",ROU)
  1. .S MVAL=^XTMP("HSED","MASTER_RSET",ROU)
  1. .I CVAL=MVAL K CVAL,MVAL Q
  1. .W !!,"Routine",?12,"Master Set",?24,"Compare Set"
  1. .W !,ROU,?12,MVAL,?24,CVAL
  1. .W !,"First 2 lines of master routine:"
  1. .F I=1:1:2 W !,$G(^XTMP("HSED","MASTER_RSET",ROU,I))
  1. .W !,"First 2 lines of ompare routine:"
  1. .F I=1:1:2 W !,$G(^XTMP("HSED","COMPARE_RSET",ROU,I))
  1. .S RCT=RCT+1
  1. .K CVAL,MVAL
  1. K ROU
  1. W !!,"Summary"
  1. I RCT>0 W !!,RCT," routines with different checksums than the MASTER SET were found."
  1. I RCT=0 W !!,"No checksum differences were found."
  1. I NIMCT>0 W !,NIMCT," routines in this UCI were not found in the MASTER SET."
  1. I NIMCT=0 W !,"Both MASTER and COMPARE contain the same routines -- the sets are identical."
  1. W !!,"**END REPORT**",!!
  1. Q
  1. ;
  1. CHKSUM(RSET) ; compute checksums for routines in RSET...
  1. ; RSET = either MASTER_RSET or COMPARE_RSET
  1. ; returns nothing -- computes checksum using ^%ZOSF("RSUM") and stores
  1. ; value at ^XTMP("HSED",<RSET>,<routine name>)=checksum value
  1. N I,ROU,X,XCNP,Y,ZZRL,ZZRLL
  1. S ZZRL="N %,%N S %N=0 X ""ZL @X F XCNP=XCNP+1:1:2 S %N=%N+1,%=$T(+%N) Q:$L(%)=0 S @(DIF_XCNP_"""",0)"""")=%"""
  1. S ROU=" "
  1. F S ROU=$O(^XTMP("HSED",RSET,ROU)) Q:ROU="" D
  1. .S X=ROU
  1. .X ^%ZOSF("RSUM")
  1. .S ^XTMP("HSED",RSET,ROU)=Y
  1. .; retrieve and store the first two lines of the routine...
  1. .K ZZRLL
  1. .S XCNP=0,DIF="ZZRLL("
  1. .X ZZRL
  1. .F I=1:1:2 S ^XTMP("HSED",RSET,ROU,I)=$G(ZZRLL(I,0))
  1. Q
  1. ;
  1. DIFF(V1,V2) ; compute difference between two values...
  1. ; V1 and V2 are numeric values
  1. ; returns difference (non-negative value) between V1 and V2
  1. I $G(V1)=""!($G(V2)="") Q 0
  1. I +V2>+V1 Q +V2-+V1
  1. Q +V1-+V2
  1. ;
  1. HELP ; help for menu option selection...
  1. W !!,"Master routine set is the set which will contain the routines"
  1. W !,"and checksum values that will be used to compare against a"
  1. W !,"routine set from another UCI. This is the master routine set"
  1. W !,"and checksum values."
  1. W !!,"Comparison routine set is the set which contains the routines"
  1. W !,"in a UCI that will be compared against the master routine set."
  1. W !!,"The report option provides a list of routines in the current"
  1. W !,"UCI that either don't exist in the master, or have different"
  1. W !,"checksum values than the value computed for a given routine in"
  1. W !,"the master routine set."
  1. W !!,"Note: ^%ZOSF(""RSUM"") is used to compute checksum values."
  1. Q