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



Adding or removing the VALUE keyword on a parameter means both the
called procedure and its callers will need to be recompiled.

Consider with a 15p0 parameter.

With VALUE
What's passed is 8 bytes containing the actual value of the variable.

Without VALUE
What's passed is 16 bytes containing a pointer to the 8 bytes of
memory holding the value.

Thus it should be obvious why you're having problems.

HTH,
Charles

On Mon, Aug 16, 2010 at 3:35 PM, Tyler, Matt <matt.tyler@xxxxxxxxxxxxxx> wrote:
We have a small function in one of our service programs that was
recently changed (no names or reasons to be given).  The change seemed
small but is having an immediate impact.



The value keyword was taken off the interface of one of the parameters
so it will be passed by reference now.  The callers were not recompiled
to use the new interface.



The passed param and receiving param are both defined exactly as 15p0.
In the function there is a blank name DS with fields.  No INZ is on the
DS definition.  The sub field is defined as 15s0.



In version 1 the system passed the callers data by value to the function
and then that value was loaded into the DS subfield.  No problems.  The
subfield loaded just fine.



Now in version 2 (the one without the value keyword) the program crashes
attempting to load the subfield with a data decimal error.



The question I want to answer is why is the function causing a data
decimal error only when passed by reference and not by value?





<code version="1">

 <interface>

    D CalcUPCChkD     PI             1P 0

    D  UPC                          15P 0 Value

 </interface>

 <blankds>

    D                 DS

    D UPCField                      15S 0

    D UPCAr                          1S 0 DIM(15) Overlay(UPCField)

 </blankds>

 <cspec>

      UPCField = UPC*10; // move to left by one

 </cspec>

</code>



<code version="2">

 <interface>

    D CalcUPCChkD     PI             1P 0

    D  UPC                          15P 0

 </interface>

 <blankds>

    D                 DS

    D UPCField                      15S 0

    D UPCAr                          1S 0 DIM(15) Overlay(UPCField)

 </blankds>

 <cspec>

      UPCField = UPC*10; // move to left by one

 </cspec>

</code>



When I check the field addressing in both versions they are all
different between the caller and callee as I would expect on anything
not call by reference (although pass by reference the addresses are very
close to each other).





Thanks for any insight, Matt



Full function code here http://code.midrange.com/461e637167.html.

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