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



Thanks Barbara;

I did not expect this behaviour, altho it makes sense. If asked previously I
would have said that the compiler would   have chocked on it with a not
enough indexes error.

Thanks again.
Duane

-----Original Message-----
From: Barbara Morris [mailto:bmorris@xxxxxxxxxx]
Sent: Monday, July 12, 2004 12:01 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: interesting array "Feature"?


"Christen, Duane J." wrote:
> 
> I just came across an interesting bug in my code. (see below)  I have a
> function which returns a value and assigning that value to an array
element.
> I had not indexed the array correctly so the function was being "called"
for
> each element. It was finally failing because not all of the storage for
the
> array was allocated. I assume, altho I have not tried it, that if the
array
> would have been fully allocated that all elements would have been assigned
a
> return value from individual function calls.
> 
> The question would be: Is this an intended feature and can I expect this
> result in the future?
> I'm currently on V5R2M0.
> 

In general, if you do "array=value", every element gets the value.  When
"value" includes a call, the call gets made every time.  The exception
is for "array=arrayproc"; a procedure returning an array is only called
once.

I'm not sure about "intended feature", but this is the expected
behaviour.  Changing it would introduce an incompatibility if the called
procedure has side-effects; for example, it reads a file and returns a
different record on every call (I don't particularly think this is a
good thing to do, but it's possible).

A prototype keyword indicating that a procedure has no side effects
would be useful.

Barbara
    ===

--
This is the RPG programming on the AS400 / iSeries (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.



NOTICE: This electronic mail transmission may contain confidential
information and is intended only for the person(s) named.  Any use, copying
or disclosure by any other person is strictly prohibited. If you have
received this transmission in error, please notify the sender via e-mail.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.