AZHLSC44 ; IHS/HQW/JN - SAC CHAPTER 2: M LANGUAGE PROGRAMMING STANDARDS & CONVENTIONS ; [ 04/15/1999 9:28 AM ]
;;5.0;AZHLSC;;JAN 17,1997
EN ;EP FIND COMMENT OR TEXT NAKED GLOBAL
S (Z(Z),Z1)=^TMP($J,"Z")
; GO CHECK FOR INITS, TEMPLATES
D EN^AZHLSC46
I AZHLSC4I=1 G AZHLSCKV
; CHECK FOR TEXT DATA
S AZHLSCF=0
D EN^AZHLSC47 I AZHLSC4I=1 Q
S Z1=Z(Z)
;I $F(Z1,";;") G AZHLISO
; FIND COMMENT LINE,IF FURTHER THAN 11, LINE OF CODE COMMENT
;S AZHLSCF=$F(Z1,";") I AZHLSCF=0 G AZHLISO
;I AZHLSCF<12 G AZHLSCKV
S AZHLSCF=0
AZHLISO ; ISOLATE NAKED GLB
S AZHLSCF=$F(Z1,"^(",AZHLSCF) G:AZHLSCF=0 AZHLSCKV
S AZHLSCF1=$F(Z1,")",AZHLSCF) G:AZHLSCF1=0 AZHLSCKV
I (AZHLSCF1-AZHLSCF)>12 G AZHLSCKV
S AZHLSCF5=$F(Z1,"DIC(""S"")=") G:AZHLSCF5>0 AZHLSCKV
S AZHLSCF5=$F(Z1,"DIC(""W"")=") G:AZHLSCF5>0 AZHLSCKV
S AZHLSCF5=$F(Z1,"DIC=""") G:AZHLSCF5>0 AZHLSCKV
S AZHLSCF2=$E(Z1,AZHLSCF,AZHLSCF1-2)
S AZHLSCF2=$P(AZHLSCF2,",",1)
S AZHLSCF3=$L(AZHLSCF2)
; SEARCH FOR FULL GLOBAL DEFINITION ON SAME LINE
; BACKWARD SEARCH FOR FULL REFERENCE
AZHLSCBW F I=AZHLSCF:-1 Q:I<1 I $E(Z1,I-1,I+AZHLSCF3-2)=AZHLSCF2 G AZHLISO
; FORWARD SEARCH
S AZHLSCF4=$L(Z1)
F I=AZHLSCF1:1:AZHLSCF4 I $E(Z1,I-1,I+AZHLSCF3-2)=AZHLSCF2 G AZHLISO
I $F(AZHLSCF2,",",2) G AZHLSCCR
AZHLSCET ; SET RECORD UP FOR REPORT
S ^TMP($J,"2.2.10",AZHL0,AZHLB)=^TMP($J,"Z")
AZHLSCKV ; KILL VARIABLES
K AZHLSCF,AZHSCF2,AZHLSCF1,AZHLSCF3,AZHLSCF4,AZHLSCF5,AZHLSCF6,Z
Q
AZHLSCCR S AZHLSCF2=$P(AZHLSCF2,",",2),AZHLSCF2=","_AZHLSCF2_")"
S AZHLSCF3=$L(AZHLSCF2)
; GO START SEARCH FOR FULL REFERENCE
G AZHLSCBW
AZHLSC44 ; IHS/HQW/JN - SAC CHAPTER 2: M LANGUAGE PROGRAMMING STANDARDS & CONVENTIONS ; [ 04/15/1999 9:28 AM ]
+1 ;;5.0;AZHLSC;;JAN 17,1997
EN ;EP FIND COMMENT OR TEXT NAKED GLOBAL
+1 SET (Z(Z),Z1)=^TMP($JOB,"Z")
+2 ; GO CHECK FOR INITS, TEMPLATES
+3 DO EN^AZHLSC46
+4 IF AZHLSC4I=1
GOTO AZHLSCKV
+5 ; CHECK FOR TEXT DATA
+6 SET AZHLSCF=0
+7 DO EN^AZHLSC47
IF AZHLSC4I=1
QUIT
+8 SET Z1=Z(Z)
+9 ;I $F(Z1,";;") G AZHLISO
+10 ; FIND COMMENT LINE,IF FURTHER THAN 11, LINE OF CODE COMMENT
+11 ;S AZHLSCF=$F(Z1,";") I AZHLSCF=0 G AZHLISO
+12 ;I AZHLSCF<12 G AZHLSCKV
+13 SET AZHLSCF=0
AZHLISO ; ISOLATE NAKED GLB
+1 SET AZHLSCF=$FIND(Z1,"^(",AZHLSCF)
IF AZHLSCF=0
GOTO AZHLSCKV
+2 SET AZHLSCF1=$FIND(Z1,")",AZHLSCF)
IF AZHLSCF1=0
GOTO AZHLSCKV
+3 IF (AZHLSCF1-AZHLSCF)>12
GOTO AZHLSCKV
+4 SET AZHLSCF5=$FIND(Z1,"DIC(""S"")=")
IF AZHLSCF5>0
GOTO AZHLSCKV
+5 SET AZHLSCF5=$FIND(Z1,"DIC(""W"")=")
IF AZHLSCF5>0
GOTO AZHLSCKV
+6 SET AZHLSCF5=$FIND(Z1,"DIC=""")
IF AZHLSCF5>0
GOTO AZHLSCKV
+7 SET AZHLSCF2=$EXTRACT(Z1,AZHLSCF,AZHLSCF1-2)
+8 SET AZHLSCF2=$PIECE(AZHLSCF2,",",1)
+9 SET AZHLSCF3=$LENGTH(AZHLSCF2)
+10 ; SEARCH FOR FULL GLOBAL DEFINITION ON SAME LINE
+11 ; BACKWARD SEARCH FOR FULL REFERENCE
AZHLSCBW FOR I=AZHLSCF:-1
IF I<1
QUIT
IF $EXTRACT(Z1,I-1,I+AZHLSCF3-2)=AZHLSCF2
GOTO AZHLISO
+1 ; FORWARD SEARCH
+2 SET AZHLSCF4=$LENGTH(Z1)
+3 FOR I=AZHLSCF1:1:AZHLSCF4
IF $EXTRACT(Z1,I-1,I+AZHLSCF3-2)=AZHLSCF2
GOTO AZHLISO
+4 IF $FIND(AZHLSCF2,",",2)
GOTO AZHLSCCR
AZHLSCET ; SET RECORD UP FOR REPORT
+1 SET ^TMP($JOB,"2.2.10",AZHL0,AZHLB)=^TMP($JOB,"Z")
AZHLSCKV ; KILL VARIABLES
+1 KILL AZHLSCF,AZHSCF2,AZHLSCF1,AZHLSCF3,AZHLSCF4,AZHLSCF5,AZHLSCF6,Z
+2 QUIT
AZHLSCCR SET AZHLSCF2=$PIECE(AZHLSCF2,",",2)
SET AZHLSCF2=","_AZHLSCF2_")"
+1 SET AZHLSCF3=$LENGTH(AZHLSCF2)
+2 ; GO START SEARCH FOR FULL REFERENCE
+3 GOTO AZHLSCBW