× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Not sure what you mean by "using sub-procedures as routines".

The global variables being used are for file i/o and the indicator DS
being used for the display file.

Also note that this program was written in 2004 on v5r2(?) or so.

I'm not putting this out there as the end-all be all, simply an
example of descriptive sub-procedures.

Charles

On Mon, Mar 1, 2010 at 10:33 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Thankyou, Charles

I note that you too, are using global variables and that you are using sub-procedures as routines. Wouldn't it be nice to be able to do away with the prototype declaration for this kind of use? (!)

The mainline logic is clear and needs almost no commenting. I feel that most programmers I know would have put the whole thing into one main procedure.

I've been using this kind of notation more and more (thanks to Aaron Bartell) :
      gDisplayFileControl.displaySubfile = ( gDtlSubfRrn > 0 );

-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt
Envoyé : lundi 1 mars 2010 14:24
À : RPG programming on the IBM i / System i
Objet : Re: More on RPG style

David,

I think you're justified.  The important thing when doing
this is to give your procedures a descriptive name.

You've got 4096 characters to use, there's no excuse for
having short cryptic names.  Don't be afraid to use the
ellipsis to create names longer than 15 characters.
     d ORDER_AddLineItem...
     d                 pr

I often use the ellipsis even with names less than 15
characters, as I often rename procedures during development
and if the ellipsis are already there renaming to a long name is easy.

Here's what I try to do, break the program into enough
routines so that the mainline fits on one screen (in WDSC of course).
In combination with descriptive procedure names, this allows a new
developer to easily get a handle on what the program does.   For
example:

       //
       // Mainline logic
       DoU gDisplayFileControl.exit
             or gDisplayFileControl.cancel;
         //
         // Check for existing subfile records to condition SFLDSP
         if gDtlSubfRrn > 0;
           gDisplayFileControl.displaySubfile = *ON;
         Else;
           gDisplayFileControl.displaySubfile = *OFF;
         endif;

         gDisplayFileControl.subfileDropMode = dspfSubfMode;

         Write MsgSubfCtl;
         ExFmt DtlSubfCtl;
         RmvMsgsFrmQ();

         select;
           when gDisplayFileControl.exit
            or gDisplayFileControl.cancel;
             iter;
           when UserEnteredNewCriteria();
             OpenCursor();
             LoadSubFile(READ_START);
           when gDisplayFileControl.printList;
             PrintListing();
             LoadSubFile(READ_START);
           when gDisplayFileControl.pagedown;
             LoadSubFile(READ_FORWARD);
           when gDisplayFileControl.pageup;
             LoadSubFile(READ_BACKWARD);
         endsl;
       enddo;
       //
       // End of program
       *INLR = *ON;
       return;


Tell me, what's the above?

HTH,
Charles


On Mon, Mar 1, 2010 at 5:44 AM, David FOXWELL
<David.FOXWELL@xxxxxxxxx> wrote:
Hi,

I tend to divide my code into subprocedures in a program
just to improve readability, even when there is very little
risk of that subprocedure being called from anywhere else.
Each subprocedure will correspond to a specific task executed
by the program.

Eg,

 /FREE

  IF not doThis ( )
     RETURN

  ENDIF;

  IF NOT DoThat ( )
     RETURN

  ENDIF;

 /END-FREE

In these cases I will use global variables unless not
possible. That leaves me with a load of one line prototype
declarations in my code :

D doThis                 PR
D doThat                 PR

I've just discovered that this style seems to annoy at
least one programmer who prefers to see all the code in one
main procedure and does not like to see all those PR's PI's
and returns, etc. Rather embarassing.

Am I justified in coding in this way or am I wrongly using
subprocedures?
--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting,
please take a
moment to review the archives at
http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change
list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.