View previous topic :: View next topic |
Author |
Message |
srinivasbathimmi Beginner
Joined: 23 Aug 2006 Posts: 2 Topics: 2
|
Posted: Wed Jul 15, 2009 6:26 am Post subject: Edit Macro to list all unused working storage variables |
|
|
Hi,
I am beginner to edit macros and thought of wirting an edit macro to list out all the unused working storage variables in a cobol program.
High level view of below peice of code is
Find line number where working storage begins (n1)
Find line number where procedure division begins (n2)
Start processing from n1 to n2
If you find any 'PIC' string then get the variable name and give a find in procedure division till .zl (last line). If it encounters leave it else display as unused vairable.
My program is working fine incase Varaibles order in working storage section is same in procedure division.
Example : Code: |
WORKING STORAGE SECTION.
01 X.
05 A PIC X(9).
05 B PIC X(2).
05 C PIC 9(2).
PROCEDURE DIVISION.
PARA1.
display A.
display B.
display C.
|
If not I am facing problem because I am doing a FIND command and not able to get the cursor back to PROCEDURE DIVISION for every field.
Is there any to solve this situation.
Could you please any one help me out
Code: |
ISREDIT MACRO
ADDRESS ISPEXEC "CONTROL ERRORS RETURN "
ADDRESS ISREDIT "(USTAT) = USER_STATE"
ADDRESS ISREDIT "(FLINE) = LINENUM .ZF"
ADDRESS ISREDIT "(LLINE) = LINENUM .ZL"
IF RC = 0 THEN
DO
ADDRESS ISREDIT "FIND 'WORKING-STORAGE SECTION'"
ADDRESS ISREDIT "(N1) = LINENUM .ZCSR"
ADDRESS ISREDIT "FIND 'PROCEDURE DIVISION'"
ADDRESS ISREDIT "(N2) = LINENUM .ZCSR"
DO I = N1 TO N2
ADDRESS ISREDIT "(VLINE) = LINE &I"
PARSE VAR VLINE WITH 7 COL7 +1 STRING 73
IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN
NOP
ELSE
DO
NO_WORD = FIND(STRING,'PIC')
IF NO_WORD <> 0 THEN
DO
FSTRING = WORD(STRING,NO_WORD-1)
IF FSTRING <> "" THEN
DO
ADDRESS ISREDIT "FIND "FSTRING""
IF RC = 0 THEN
DO
SAY 'VAR : ' FSTRING
ADDRESS ISREDIT "(PLINE) = LINE .ZCSR"
PARSE VAR PLINE WITH 7 COL7 +1 STRING 73
IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN
SAY 'NOT FOUND1: ' FSTRING
END
ELSE
SAY 'NOT FOUND:' FSTRING
END
ELSE
ELSE
NOP
END
END
END
EXIT. |
|
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jul 15, 2009 6:48 am Post subject: |
|
|
look at the CROSS-REFERENCE OF DATA NAMES portion of the compiler output and
only delete those which have no reference within the structure.
Problem with writting a macro for a COBOL source program, you are not able to take into account copybooks in working-storage, includes in working-storage, and most importantly, procedureal copybooks.
once you have found procedure division and working-storage, label them. then to reposition the cursor, you only have to use a locate. but, since you have the lineno of procedure division, you can always include that in your FIND command as range parms: l-no-procdiv .zlst.
learn to use BBcode when you post your code; it is easier to read. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|