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



Doh!! I knew it was something stupid like that. RPG is smarter than me in this case.

Thanks Barbara!

Sent from my iPod

On Sep 28, 2009, at 4:38 PM, Barbara Morris <bmorris@xxxxxxxxxx> wrote:

Mike Wills wrote:
I am experiencing a weird error when debugging a subprocedure. The program
runs through properly then after it hits the return statement, it runs
again, and again, and again. I have not manually run it until it "pukes" but
when it finally returns data back to my calling app, I get bad data.

Calling statement:
tempChar = ParseEmailAddresses(cEmail); //receiver field defined
as 100A dim(327)


Called subprocedure which takes a semicolon delimited string of email
addresses and breaks them into an array.
P ParseEmailAddresses...
P B EXPORT
D ParseEmailAddresses...
D PI 32700A
D toParse 32767A CONST


Mike, you have defined your procedure as returning 32700A, and your
receiver field as 100A dim(327). I think you are intending for the
32700A returned value to be split up into the 327 100A elements, but
what actually happens is that the entire return value is assigned to
each element of the 100A array. So each element is getting the first 100
bytes of the 32700A return value.

One way to fix it would be to define your receiver field as a 32700 DS
with a 100A array dim(327) subfield.

The reason your procedure is getting called over and over:

When you code like this in RPG
array = nonarray;
the compiler generates code like this:
for i = 1 to number of elements in array;
array(i) = nonarray;
endfor;

The compiler evaluates the right-hand side of the expression for each
iteration of this loop, so your procedure gets called 327 times.
--
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.