MC Press Web Site Staff
This is a discussion about [B>TechTip: RPG IV--What\'s Different About Programming Structures in Free-Format?[/b>.

Click here for the article.

avrahamn@coop.co.il
It is easier to see and analyze the code. All variables being changed are in the result filed position. The same way as elimnating the GOTO statement, You could eliminate many other bad code. In my opinion to many nested levles of if-do-else confuses. In such a case it is better to use subroutines and procedures. But to many nested short subroutines and short procedures is also confusing. So you have to be balanced. EVAL statement could be easy to understand if it is not to complex, but if You make it complex it also bad code. Example of free code that is hard to understand and follow: A=(B+C)/%ELEM(a1)* proc1(J+G:proc2(K:M)). From the other Side, 1 or 2 goto staments in a program does not make the program unreadble: Screen1 TAG EXFMT SCREEN1 IF EXIT EXSR ENDPGM ENDIF EXSR PROCESS1 IF ERROR1 GOTO SCREEN1 ENDIF SCREEN2 TAG EXFMT SCREEN2 IF PREVIOUS GOTO SCREEN1 ENDIF GOTO SCREEN2 Here You have a short program tha did not abuse neither the use of to many levels of nested DO and not to many GOTO. The logic is very similar to our thinking. The bad opinion about GOTO goes back to the days of indicators when there was no IF and DO. Now when we have those codes, we could write a nice balanced program that uses all tools that are the most appropriate.
derek_111
When you say its easier to read because all changed fields are in the result column, i think that it is easier because that is what you are used to reading. Myself, i am more used to free form, so it is much easier for me to read the other way. So, which is easier could be argued all day long, but it basically comes down to what you are used to using that makes a difference in what is easier to read for different people. One big advantage for me when i\'m reading free form is the tabbing. I can quickly see the flow of the logic by just looking at where things are tabbed. I can see the main loop because it is all the way to the left, i know that everything tabbed over is going to be executed everytime through the loop. With fixed format, i would have to count the number of endifs, and enddos and so on till i find the one that matches up with the one i want. anyways, just my opinion.
dwiesner@charter.net
I have been a proponent of using do loops instead of goto\'s for many years. Whenever someone would use the excuse that a program was small so it didn\'t matter, I always heard in the back of my mind "If you don\'t do it in the small programs, why would you start in the larger programs?" But I do agree, there must be balance. I have worked on COBOL converted from a mainframe and there are procedure calls to execute one line of code.
uptech
You can line up your code using free format. Indent the nested if\'s and do\'s. It\'s easy and it\'s great! And you get back all that "white space" on the left "formerly" occupied by the total-time indicators, the indicatora, factor 1, plus!
buck.calabro@commsoft.net
> When some problem arise, I like to be able to see which > lines I have changed the last time I (or someone else) > changed the program. Before I would look at the date > part of the source in SEU to identify those lines. How does one find lines that were deleted by looking at the source date? Please don\'t tell me that you comment them out and leave them in the code. I have had to work in such a shop and I would rather slash my wrists with a rusty tuna can lid than do that again. Far better is to use a change management package to show the changes between versions. --buck
kaj@maxjenne.dk
In general I like the /free format RPG that allows me to indent my code, thereby making the code more readable. However I have also discovered something that has made me a bit reluctant to use it. When some problem arise, I like to be able to see which lines I have changed the last time I (or someone else) changed the program. Before I would look at the date part of the source in SEU to identify those lines. But because every block of code that has to be shifted, either to the right or to the left also changes the date, I can no longer use this information to identify when a change last occured. [i> In my oppinion IBM has to change this behavior of SEU as soon as possible.[/i>
cramer@multi-support.dk
I don\'t think there is much difference in using goto or iter (or leave). Iter (and leave) opcodes are also goto statements. Iter means go to the beginning of the loop (leave means go to the first statement after the loop ie enddo). I would prefer to use the example given without any Iter (and leave) opcode. It can be done - I use the select statement insted of repetetive if blocks with the Iter opcode. Or, if as in the example you only whants to set a display format indicater you could use the following: Eval *in20 = Error_1 Eval *in21 = Error_2 or Eval *in20 = (Error_1 = \'1\') or something similar. This is a direct way to compute the indicator value (leaving a lot of code behind). But don\'t create a too complex eval statement (as the example in an earlier reply) without good commenting the statement.
ACT
With Free format RPG should be renamed to PL/I. My two cents.
avrahamn@coop.co.il
But in CL, if there is a big CL program, with some logic in it, it is hard to follow. I agree tha the result indicators need to be taken away, and the same also L and detail indicators. But the RPG Cycle, when it comes to control Breaks, there is no alternative to it.
Please login to make comments.
User Rating: / 0
PoorBest 

WHITE PAPERS

The following White Papers can be found at the MC White Paper Center

 

 


   MC-STORE.COM