× 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.



Where do you see Barbara using a return variable?

You can't have a returned variable on a program.

Charles

On Wed, Feb 2, 2011 at 7:42 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Thanks a lot.

I need to revise using MAIN. I have been using it systematically when I don't need the cycle.

I did not realise you could use a return variable. It is not documented in the nice comparison table here :
http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp?topic=/rzasd/sc09250889.htm

Where can I see that documented?

This is interesting for us as we sometimes use program calls instead of bound procedure calls for technical reasons and so lose the possibility of having a return variable.


-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Barbara Morris
Envoyé : mardi 1 février 2011 18:47
À : rpg400-l@xxxxxxxxxxxx
Objet : Re: recursive calls


If you'd use MAIN, then you do make a recursive program call
when you call using the main-procedure prototype.

The prototype looks like this:

D mypgm         pr            extpgm('MYPGM')

If you code
    callp mypgm
it calls program *LIBL/MYPGM.  It doesn't make a bound call
to the actual main procedure.

You would be able to tell the difference if it was a *NEW
program.  If it did call the main procedure directly, both
calls would be in the same activation group.  But since it
calls the program, you would get a different *NEW activation group.

For the program at the end of this message, I set a
breakpoint in the main procedure, and on the second time it
gets hit, I look at the program stack (I merged two different
views of the program stack here).
  You can see that the second call is in a different *NEW
activation group (actgrp numbers 51 and 52), and that it got
to the main procedure via the PEP which indicates that it
really was a program call.

                                    ---Activation Group---  Control
Program          Procedure         Name   Number           Boundary

NEWPGM  BMORRIS  _QRNP_PEP_NEWPGM  *NEW   0000000000000051  Yes
NEWPGM  BMORRIS  NEWPGM            *NEW   0000000000000051  No
NEWPGM  BMORRIS  _QRNP_PEP_NEWPGM  *NEW   0000000000000052  Yes
NEWPGM  BMORRIS  NEWPGM            *NEW   0000000000000052  No

Here's the program:

h main(newpgm) actgrp(*new)
D static          s             10a

D newpgm          pr                  extpgm('NEWPGM')
D   call_again                    n   const

P newpgm          b
D newpgm          pi
D   call_again                    n   const
  /free
     if call_again;
        static = 'abcde';
        newpgm ('0');
     endif;
  /end-free
P newpgm          e


--
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.