IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX tool to remove dead codes


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
deepak.kec

New User


Joined: 26 Feb 2007
Posts: 71
Location: bangalore

PostPosted: Thu May 14, 2009 8:18 pm
Reply with quote

Hi All,

Did some one has any REXX tool to remove dead codes from a cobol program?

Suggestion to write such a tool will also be helpful.

Thanks to all for providing me help and support.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu May 14, 2009 8:24 pm
Reply with quote

Once You define exactly what You mean by "dead code"
writing such a tool would range from easy to impossible (*) icon_cool.gif

(*) looking at the source code only
Back to top
View user's profile Send private message
deepak.kec

New User


Joined: 26 Feb 2007
Posts: 71
Location: bangalore

PostPosted: Thu May 14, 2009 8:49 pm
Reply with quote

i mean to say that source code which is commented out and is present along the source code.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 14, 2009 9:03 pm
Reply with quote

differentiating between comments and 'commented code' is rather difficult,
if not impossible.

Dead code is usually a reference to code that will never be executed.

removal of comments from a source module, will only reduce the size of the source module. will have no effect on the object.

but, in answer to your question.

a REXX EDIT macro easily can distinguish between comments and those lines which are not comments.
FIND 'PROCEDURE DIV' first, hoping of course that the Procedure Div statement is not in a copybook.
FIND '*' 7 will do the trick, but you have to insure that the bounds include the lineno columns (1-6).
find_RC = RC
create a do loop
if find_rc <> 0 then exit the loop
you could then load the source line via an ISPF Macro LINE command.
once into a REXX variable the fun begins.
How to interrogate the data in the variable to determine if it is indeed 'commented code' or a real comment?

Once you have determined if it is 'dead code', you can issue an ISPF Macro DELETE .zcurr
then as last instruction in the DO Loop, F '*' 7 next
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Thu May 14, 2009 9:35 pm
Reply with quote

Does your 'dead code' really happen that often that you need to write a program?

I suggest excluding all the lines, then find all with '*' in col 7 (or whatever it is) then scroll up and down while deleting the problem lines.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri May 15, 2009 9:02 am
Reply with quote

I don't remember which version of COBOL it was, but I remember seeing a compile listing where dead code was documented at the bottom of the listing. It could then be removed manually. Why write a REXX program if the compiler will spot it for you?
Back to top
View user's profile Send private message
deepak.kec

New User


Joined: 26 Feb 2007
Posts: 71
Location: bangalore

PostPosted: Fri May 15, 2009 1:19 pm
Reply with quote

We use Cobol version 2 but the compiler doesn't document the dead code at the bottow.

Dead Code are the redundant code which have been commented and are of no use now.


thanks Dick Brenholtz. Hope ur suggestion helps me icon_smile.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri May 15, 2009 3:12 pm
Reply with quote

This link talks about a similar topic: www.ibmmainframes.com/viewtopic.php?t=35505&highlight=unused
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri May 15, 2009 6:25 pm
Reply with quote

The "dead code" I was referring to is code that will never be executed because of the logic coded, for instance a paragraph that is never performed or cannot be executed because of "fall through" logic. The compiler stated that no instructions were generated in the object module since the code will never be executed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top