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

Replace all GOTO statements with Perform


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 17, 2011 8:52 pm
Reply with quote

Hi, I have a requitrement to repalce all GOTOs with Perform. Can anyone suggest any tips for this?

thanks
Krisprems
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 17, 2011 8:53 pm
Reply with quote

FYI, I have 500+ GoTo statements ...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Oct 17, 2011 9:36 pm
Reply with quote

Quote:
Can anyone suggest any tips for this?


unfortunately not, the only tip is... start coding icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 17, 2011 9:45 pm
Reply with quote

Hello,

Keep in mind that many GO TO statements are not directly replacable by a PERFORM.

Is there no real work to be done? This will probably take quite a lot of time and may introduce many problems if the testing is not most comprehensive. Is this all one program or many?

What business reason is there to do this at this point? And no, this is not a business "requirement". You may be stuck doing this, but the reason is probably just because someone wants it (and not the users).

If this is to make the code more maintainable, suggest you consider re-writing the code from the specs rather than trying to salvage the existing code.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Oct 17, 2011 9:47 pm
Reply with quote

If you have one program with 500+ GO TOs, you'd be better off starting from scratch.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2480
Location: Netherlands, Amstelveen

PostPosted: Mon Oct 17, 2011 9:59 pm
Reply with quote

krisprems wrote:
FYI, I have 500+ GoTo statements ...


Going to the same statement?
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Oct 17, 2011 11:22 pm
Reply with quote

Wait...

You realize that a PERFORM statement comes back when it's done, right? While a go to does NOT come back.

So you cant just "replace" a go to with a PERFORM. You have to change how the program flows.

Can you give a short example of one or two of the go to statements you have to replace?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Oct 18, 2011 4:35 pm
Reply with quote

I don't think its worth getting too bogged down worrying about using GO TO's or not, or PERFORM THRU's. What is more relevant is what do the existing programs do?

In short, there is no direct approach. It'll take time and effort.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Tue Oct 18, 2011 5:13 pm
Reply with quote

If you do proceed, do a few at a time in one section of the program, then perform complete testing.

If you do too many and testing fails, you'll be lost.

I do presume you have a complete test plan ... ?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Oct 18, 2011 6:31 pm
Reply with quote

All thanks for your inputs!

cheers
Krisprems
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Oct 18, 2011 8:04 pm
Reply with quote

That's it? No more actual detail? Leave us all hanging as to whether you ever see the light again after entering the GO-TO-Pit-of-Doom....

Good luck then :-)
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed Oct 19, 2011 3:26 am
Reply with quote

He must have left a go to in the wrong place!



Code:

Procedure division
    perform post-message
    perform wait-for-answers
    Go to end-interaction
    perform make-code-changes
     until changes-are-done
    perform test-changes
     until changes-are-correct
    perform post-follow-up
goback.

End-interaction.
    post thank you
    goback
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Wed Oct 19, 2011 5:32 pm
Reply with quote

Maybe he's performing everything now and keeps returning to the same place.

Reminds me of that great Star Trek time-loop episode with the poker game.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 19, 2011 5:54 pm
Reply with quote

Ph... er, Phil, Are you thinking of the episode where they were trying to throw away a boomerang?

Or was it a Frisbee?
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Wed Oct 19, 2011 5:58 pm
Reply with quote

No - An older Starfleet vessel kept coming out of a space/time thingy and they kept crashing - only to return back to the poker game after each commercial break (amazing timing in its own). Deja vu kept getting stronger, and they eventually found a way to transmit a bit of info via lt. Cmd. Data's circuitry into the next cycle that Capt. Riker's suggestion to avoid the collision was the right one.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 782
Location: Pennsylvania

PostPosted: Wed Oct 19, 2011 6:18 pm
Reply with quote

I was in my own time warp trying to recall Capt. Kirk playing poker with Mr. Spok.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 19, 2011 8:04 pm
Reply with quote

Mine was my latest contribution to "Give an Old Joke a New Home Week".

I suspect that Mr Spock was a bit of a wizz at "Enterprise Cobol".

Capt Kirk, as piece of wood flies off into the distance and stays away this time, "I did it!".
Mr Spock, raising one eyebrow, "According to my Tri-corder, sir, that was a stick".
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Oct 20, 2011 12:02 am
Reply with quote

"Cause and Effect"

http://en.memory-alpha.org/wiki/Cause_and_Effect_%28episode%29
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Oct 20, 2011 12:56 am
Reply with quote

Quote:
...that Capt. Riker's suggestion to avoid the collision was the right one.


I'm intrigued (but not enough to look at the link), what, previously, did they think was better advice than "avoid the collision!"?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Oct 20, 2011 1:01 am
Reply with quote

Bill Woodger wrote:
Quote:
...that Capt. Riker's suggestion to avoid the collision was the right one.


I'm intrigued (but not enough to look at the link), what, previously, did they think was better advice than "avoid the collision!"?

But they wanted a JCL that would do that for them! icon_lol.gif
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Thu Oct 20, 2011 1:10 am
Reply with quote

There were alternate opinions of how to move the ship out of the way. Enterprise was without warp drive or impulse drive. Riker's suggestion was to pop open the shuttle bay and let the rush of air jet-propel the ship out of the way. The other option was to use the tractor beam.

Since data had kept seeing the number "3", he went with Riker's option because Riker has three pips on his collar.

I messed up the above link...here is the correct link:
http://en.memory-alpha.org/wiki/Cause_and_Effect_%28episode%29
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Thu Oct 20, 2011 5:30 pm
Reply with quote

Ed has answered - thanks.

I'll add: previously Riker made his suggestion each time, but Data overrode it each time, leading to catastrophe. Finally, as Ed says, the clue transmitted to the final loop led Data to take Riker's idea.

A GREAT show if you ask me. Someone asked, right?

Oh, now I remember, the question was about GOTO and PERFORM!

hahahahahahaha
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Conditional replace values in output ... DFSORT/ICETOOL 3
No new posts Replace a string in a VB file and cop... DFSORT/ICETOOL 2
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts How to replace string in dataset1 fro... DFSORT/ICETOOL 3
No new posts Read file names from existing file th... DFSORT/ICETOOL 6
Search our Forums:

Back to Top