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

I should know better than to disagree with you, but I'm going to do it
anyway <grin> If I'm wrong, I'll learn something :)

I really don't see where it is necessary to set the variable to it's
maximum length as shown.
%len(Input_String) = %size(Input_String)-VARPREF (VAPREF is 2)

Input_String has a fixed number of bytes allocated, no matter what the
%len() is currently set to. As long as that allocated size is passed
to Rdline correctly, there should be no problems.


Len = RdLine( cli
: %addr(Input_String) + VARPREF
: %size(Input_String) - VARPREF
: *On );

If (len < 1);
%len(Input_String) = 0;
callp Die('Error calling RdLine()');
callp close(cli);
return;
Else;
%len(Input_String) = len;
Endif;


Charles


On Wed, Jul 15, 2009 at 6:40 PM, Scott Klement<rpg400-l@xxxxxxxxxxxxxxxx> wrote:
Hi Jon,

Seems to me that you still have to set the string to it's maximum length
before calling rdline() and set it back to the correct length after
calling rdline().

So you can't eliminate all that code.  The only thing you can do is
change %addr(var)+VARPREF into %addr(var:*data).  You can't eliminate
the rest like you suggested.


Jon Paris wrote:
Just to get the complete picture in place for the archives ...

If using V6R1 (or 6.1 as it is now known) the easiest way to handle
the data portion of a variable length field by address is to code
using %Addr( fieldName: *Data) which will automagically skip the first
two or four bytes as appropriate. So these:two lines

%len(Input_String) = %size(Input_String)-VARPREF    (VAPREF is 2)


Len = RdLine( cli : %addr(Input_String) + VARPREF :
%len(Input_String) :
*On );

Can be simplified to one - and of course the constant VARPREF is not
required either.

Len = RdLine( cli : %addr(Input_String: *Data): %len(Input_String) :


Jon Paris

www.Partner400.com
www.SystemiDeveloper.com



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

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.