If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Does anyone have a small example of how to perform a goto and a tag in free formatted RPG. I looked for some but couldn't find any. My book RPGIV free format isn't much help.
Hi, the goto and tag are not supported in the /free version. These are 2 of the ugliest things you could use in a program. Just what are you trying to do?
Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply
Actually, I find places where I like to use GOTO. No, you don't NEED to have it, but you don't NEED Do loops either. But we use them because they make coding easier to read and/or write.
For example, I have a pgm with 13,000 calc lines and a dozen IF blocks. But we test in the first ten lines for a condition where we want to skip all the calcs. So I could do an IF block that is 12,990 lines long, or I could do a single GOTO EXIT command with a TAG at the end of the calcs.
Is it better? Matter of preference, I say. Hey, sometimes I use it just to upset my peers.
I know what your saying every now and again I like to slip in a
LeaveSR opcode and If im feeling particularly evil I will put an indicator
on an enddo and setoff in the loop... Thats good for a small laugh
All my answers were extracted from the "Big Dummy's Guide to the As400"
and I take no responsibility for any of them.
Easier when moding to just patch here and there rather than rewrite the
application to our liking.....much faster also.
I agree with the above. I'm supporting code that started out on the system 34 and was migrated through the system 36 and ended up as rpgle. I'm not going to spend the time/effort to make it current code unless there is a real requirement for enhancement.
IF IT AIN'T BROKE DON'T FIX IT
I do however do these updates as time permits (only 50 or so left).
GLS
The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln
Arrow, why not just use subroutines instead of having 13k in lines.
I wouldn't write a pgm that big (not me!). Inherited from Mapics RPG-III. But I use this as an illustration. GOTO's earned a very bad reputation because of spaghetti code. But used (very) carefully, they can still be very useful.
However, its not worth enough to get me to ask IBM for it in free-format.
Well it does not take much time to grab a section of code, say 4000 lines and move them to there own subroutine and insert the name of the subroutine where the code was. Rinse and repeat.
Why do this? because if this program has been modified that many times why not make it so the next programmer does not have to read through 13k in lines to understand where to place their one line of code.
If the code is always just rigged for the last change, then you are only making matters worse ( and more expensive) for the next fellow.
Shouldn't we leave the code better than we left it.
Shot me when ready.
Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply
Comment