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



Maybe this will help:
d Proc1 pr
d data * const

d Proc2 pr
d data * value

d Proc3 pr
d data *

d Proc4 pr
d data 10a const

d Proc5 pr
d data 10a value

d Proc6 pr
d data 10a

d myData s 10a inz('Charles')

//assume the following value = x'00000001'
d ptrToMyData s * inz(%addr(myData))

//assume the following value = x'0000000B'
d ptrToPtrToMyData...
d s * inz(%addr(ptrToMyData))

/free

//Pass by const reference
// a temporary variable is built containing the value x'00000001'
// the address of the temp variable, say x'0000000A1'
// is placed on the stack
Proc1(%addr(myData));

//Pass by reference
// This will fail to compile,
// RNF7542 - Parameter 1 not valid as a parameter passed by reference
Proc3(%addr(myData));

//Pass by reference
// this works and the value x'0000000B' is placed on the stack
Proc3(ptrToMyData);

//Pass by const reference
// a temporary variable is built containing the value x'00000001'
// the address of the temp variable, say x'0000000B1'
// is placed on the stack
Proc4('Charles');

//Pass by const reference
// No temp var needed here
// value of x'00000001' is placed on the stack
Proc4(myData);

//Pass by reference
// This will fail to compile,
// RNF7542 - Parameter 1 not valid as a parameter passed by reference
Proc6('Charles');

//Pass by reference
// this works and the value x'00000001' is placed on the stack
Proc6(myData);

//Pass by Value
// the value x'00000001' is placed on the stack
Proc2(%addr(myData));

//Pass by Value
// the value x'00000001' is placed on the stack
Proc2(ptrToMyData);

//Pass by Value
// the value 'Charles ' is placed on the stack
Proc5('Charles');

//Pass by Value
// the value 'Charles ' is placed on the stack
Proc5(myData);

*INLR = *ON;
return;
/end-free


As you can see passing a variable by reference, with or without CONST,
is the same as passing the address of the variable by VALUE.


HTH,
Charles


On Thu, Jul 22, 2010 at 9:29 AM, hockchai Lim
<lim.hock-chai@xxxxxxxxxxxxxxx> wrote:
Hey Simon,
care to explain a bit more about the different between these three
prototype?
D proc1           pr
D  data                           *   const


D proc1           pr
D  data                           *   value


D proc1           pr
D  data                           *


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.