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



Scott,

Never ever ever use %ADDR() or a pointer when you've coded
OPTIONS(*STRING) on the prototype.


Actually, you might considering adding "in this context" as this is not a
blanket rule.

"* VALUE OPTION(*STRING)" parameters copy non-pointer values passed on those
parameters to a work variable whose length is at least %len(parmVar)+1. Then a
null is added in the +1 position. 
When passing IFS names, your rule is a good standard and should be followed.
But in some situations, albeit more rare situations, passing %addr() is not only
acceptable, it is more useful.

For example, suppose you have a subprocedure that accepts data in parm 1 (which
is "* VALUE OPTION(*STRING) and the length of that data in parm 2. 
In some situations, the data being sent to the proc is just text so you pass it
like this:

   foo( szData : %len(szData));

The system passes the data to the subproc, and it can be accessed. The Null
terminator is added, but can be ignored because the second parm is specified.

No suppose you have a user space. In that user space is some data that you want
to pass to the subprocedure. If that data is greater than 64k in length, you
can't declare a based variable and pass it, like you would normal fields.
But you can do this:
  Qusptrus('QGPL/MYSTUFF' : pData : apiErrorDS);
  foo(pData : 1000000);

This passes the address of the data in the user space, and tells the subproc
that it is 1 megabyte in size. No conversion is performed and the pointer to
that data is passed to the foo() subprocedure. 

A rare situation, but nonetheless important.

-Bob Cozzi
www.i5PodCast.com
Ask your manager to watch i5 TV




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.