Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed for cobolprogrammers 2

Status
Not open for further replies.

Truusvlugindewind

Programmer
Jun 5, 2002
350
NL
Sed, not sad...

Suppose you're maintaining cobol sources at a site and they have a rule never to remove code, but put an * in col7, so they have change-history. So, when you're scanning sources you constantly stumble over interesting history-lessons about that source, but you're interested in the actual "state of affairs" (stand van zaken).

Sounds familiar?

In my case I have downloaded all sources on a linux-machine so I can do impact analyses using "grep" (just scanning all sources) and guess what: a lot of history lessons...

If I only could remove those commented lines from my source...

Well, you can, using "sed". A unix/linux utility with (from a cobol's point-of-view) very criptical syntax. Believe it or not but when you run this script:
Code:
$ cat omitComment.sh
#!/bin/sh
sed  '/\*.\{7\}/d' < ${1}
using a cobolsourcefile as input, you will get your 'pure' cobol source as output!

You cannot implement that version back at the client's site but you can use that for impact-analyses or compile it for your debugging-session.

P.S. when you are stuck to windows, you can install sed from here:
 
Wow, that's pretty nifty! Does it remove all comments, though? How will it determine what's archived COBOL and what's just comments?

-------------------------
Just call me Captain Awesome.
 
No, all lines with a "*" in column 7 are out.
 
Grande,

Considering the fact that, even if accurate when created, comments tend not to be maintained properly. Therefore, one is probably better off with the comments being removed along with the 'history'.

It is saddening to know that this type of 'archival clutter' exists (far too often) when there have been source maintenance tools available for four decades that will keep this history neatly hidden away but available if one wants to see it.

Tom Morrison
 
No, all lines with a "*" in column 7 are out.
Really ? Have you even tested it ?
 
Sorry, hit submit toofast.
Your sed script actually removes all lines containing a "*" followed by at least 7 characters.
Tip: man sed
 
k5tm,
From what I've seen, all comments are kept up to date here. Although, for the most part, comments a limited to the revision history, general overview of the program, and a little blurb at the top of each paragraph...

And then PHV comes in with the man pages. Man, flash back to school...

-------------------------
Just call me Captain Awesome.
 
Well, Captain Awesome [smile], I think you are an exception. But have you really audited the revision history to see if it is accurate? [wink]

Tom Morrison
 
And the same thing can be done very easily in COBOL also. Then it is portable to all your COBOL environments without the need for cygwin (which by the way is not required to run SED on a Windows machine).

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
k5tm, it seems to be correct to the best of my knowledge. All 24 revisions of the program are there and correct, along with "Acceptance Codes."

In the code, I see
Code:
This is original code.
**** A429665 Starts Here ****
This is revised code.
**** A429665 Ends Here   ****
This is more original code.
(where A429665 is the Acceptance Code).

-------------------------
Just call me Captain Awesome.
 
Well, it works for me. I've got a subdir on a linux-machine containing a "clean" version of all the sources. I use it for impact analysis and browsing thru. Sometimes more than half of a source contains "used-to-be-code". I find that very confusing to read/grep.

And, using vim, I can edit/browse cobol code with nice syntax color[/color green]ring (hardly correct english I'm afraid). I used this
 
Every time I modify code, I archive the old version in "OBSOLETe.ZIP" with a version number replacing the extension. I have do not yet have over 99 versions of any program or copybook, but this system allows up to 999 versions.

This eliminates all the "revision history" clutter, but using VCOMP.EXE in can see all the revision history I want when I need to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top