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


  • Subject: Re: Procedure Problem
  • From: "David Morris" <dmorris@xxxxxxxxxxxxx>
  • Date: Tue, 21 Dec 1999 12:29:46 -0700

Mark & Scott,

On V3R2 you do not have very many options. On V4R2+ I would opt to 
pass my input string as a varying length CONST field.  I do not have the 
source handy for a center string I have been using, but the prototype is 
something like:

DCntStr           PR    32765A    VARYING
D InpStr                     32765A    VARYING CONST
D OptOutStrL                    5U 0 OPTIONS(*NOPASS) CONST

Using varying strings you can make your procedure work a lot more 
like IBM's built-in functions. They also get around the parameter type 
limitations imposed by OPDESC.

David Morris

>>> infosys@klements.com 12/20/99 04:39PM >>>
Hi Mark,
...
First of all, lets take a look at your prototype...   Note that you
are passing your parameters by REFERENCE as opposed to passing it
by VALUE.  Passing by reference is the default method, and its
certainly the one that I prefer for passing strings, since its
faster, and you can return changes to the string and have it be
changed in the calling routine.  However, please understand that
this means that the compiler is actually passing the ADDRESS
in main storage to your procedure, *NOT* the values of the bytes
that are stored there!
...
A few things pop into my mind.   First, its important that when
you use OPTIONS(*VARSIZE) that you find out the length of the
original variable thats being passed, and make sure you ONLY use
THAT MUCH of the variable.  (Imagine if you were changing the
data that was passed!  If you're not careful, you could end up
accidentally changing the values of other variables in memory!!!)
Presumably, this is why you're passing the Len parameter to begin
with!

Second, you could simply remove the options(*varsize) from your
prototype/interface.  What good is it really doing you?  This way,
you could use "instring" as a 256 byte string without any problems.

Third, if you do want to use options(*varsize) you could use an
operational descriptor to get the string length, and then make
sure that you only reference that length of data...
...
Hope that helps!
...
> Mark Walter


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


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.