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



Dan,

There's two way's to do this, the first is to remove the 'VALUE' from Z_ACGAMT 
and Z_AMTERR which passes the variable by reference instead of by value so you 
can modify it in your subprocedure. Passing by value (which is what you do when 
you add VALUE to a parameter definition) is similar to declaring a constant in 
that you can't change it in the subprocedure.

A better way would be to create a data structure for these two values and 
return the data structure just like you would when dealing with API's. This 
makes the program much easier to maintain if you need to return another field 
in the future. To do this, you'd do something like this:

DMyDS             DS
D Z_ACGAMT                       8S 2
D Z_AMTERR                      30A


D CVTA2N          PR                  LIKE(MyDS)
D   ACGAMT                      10A   VALUE

C               eval     MyDS = CVTA2N(ACGAMT)

P CVTA2N          B
D CVTA2N          PI                  LIKE(MyDS)
D   ACGAMT                      10A   VALUE

DMyDS2            DS
D   X_ACGAMT                     8S 2
D   X_AMTERR                    30A
<snip>
C    .........  EVAL      X_ACGAMT = N_ACGAMT
C    .........  RETURN    MyDS2
P                 E

Matt
-----Original Message-----
From: D B [mailto:dbcerpg@yahoo.com]
Sent: Thursday, November 07, 2002 8:53 AM
To: rpg400-l@midrange.com
Subject: subprocedure questions


I'm an old hand at RPG-IV coding, but a newbie with
subprocedures.  I'd like to isolate a new subroutine
into a subprocedure, mostly for isolating the
subprocedure's variables but also to get started in
using procedures.  I have glossed over the
easy-to-read-NOT F.M., in fact, followed an example of
a subprocedure it provided.

I have a working version of a very simple program
using the SUBROUTINE; this program works.  I copied
the source into another source and converted the
subroutine into a SUBPROCEDURE, and got it to compile
after several mods, but the results from the
subprocedure are not coming back to the main module.

Here's the procedure definition and the CALLP in the
main module:

     D CVTA2N          PR
     D   ACGAMT                      10A   VALUE
     D   N_ACGAMT                     8S 2 VALUE
     D   Z_AMTERR                    30A   VALUE

     C    .......   CALLP     CVTA2N(ACGAMT :
                                     N_ACGAMT :
                                     Z_AMTERR )

Here's the procedure module:

     P CVTA2N          B
     D CVTA2N          PI
     D   ACGAMT                      10A   VALUE
     D   Z_ACGAMT                     8S 2 VALUE
     D   Z_AMTERR                    30A   VALUE
<snip>
     C    .........  EVAL      Z_ACGAMT = N_ACGAMT
     C    .........  RETURN
     P                 E

I am attempting to return the values for Z_ACGAMT and
Z_AMTERR back to the main module, but am getting
nothing.

Any hints?

TIA, Dan

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
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 ...

Follow-Ups:

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.