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



Wouldn't it be better to define and pass a varying length string (64K or
even larger) with CONST (constant reference)?
In this way only a pointer is passed. If the definition of the passed
value/variable is identical to the defined parameter the address of the
original variable is passed. Only if it do not match a temporary variable in
the expected definition is created and initialized and finally the address
of this temporary field is passedl

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Alan
Campin
Gesendet: Sunday, 12.4 2015 07:32
An: RPG programming on the IBM i (AS/400 and iSeries)
Betreff: Re: Varying fields as parameters on procedure calls.

Old article by Bob Cozzi and now I can't find it again. Maybe somebody else
can find it.

I wrote a test program and proved that it sending the whole thing. I passed
a 64K varying string by value a million times and then ran the same thing
passing the string by using *STRING and *TRIM and basically it was 38 times
faster. The *STRING was passing the actual 17 bytes and the by Value was
sending the whole 64K each time so basically I answered my own question. I
know it always passed the whole thing but Cozzi was saying that it only
passed the actual length which made no sense to me.

On Sat, Apr 11, 2015 at 9:47 PM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
wrote:

Alan,

Can you point to this article you're referring to? I'd like to
understand what you're referring to.

There's nothing magic about VARYING data types -- they work the same
as any other data type. When you pass by VALUE the variable is copied
-- the whole thing is copied, so if you had 1000A VARYING, it'd copy 1002
bytes
from the caller to the procedure. When passed by reference (i.e. no
VALUE
keyword) than a pointer (16 bytes) is passed instead, and it shares
the same memory as the caller.

Personally, because I often interface with other languages like C,
C++, SQL, etc I would never pass a character string by value. Many
languages don't allow it (or allow it, but make it difficult, for
instance in C you have to use a data structure to pass a a character
string by value.) So I would avoid passing a string by value... (I
only use value for numerics)

The article you're referring to may be referring to something like return
values, maybe? I would like to see it to understand it...

-SK



On 4/10/2015 6:13 PM, Alan Campin wrote:

Just a quick question. I was reading on article on the web and it
stated that if I had a varying fields that what would get passed by
VALUE would be just the first two digits for the length and the
actual length of the data.

It has always been my understanding if I had field that was 64K
varying and I passed it as a parameter that the 64K plus two (or
four) bytes for the length is what would be passed even I only had
say 10 bytes of data.

Since a statement like InParm = *ALL'*'; is valid even though it
would never be seen by the caller, I don't see any other way it could
work except to the pass the entire length.

I can pass as *VARSIZE but only if a CONST or by reference or I can
pass as *STRING with an optional *TRIM which is what I have been
doing lately.

--
This is the RPG programming on the IBM i (AS/400 and 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.


--
This is the RPG programming on the IBM i (AS/400 and 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.



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.