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



To say just a bit more, as I often do - I do recommend, if possible, to change over to varying-length alpha variables. The benefit can be great.

There is YMMV going on here, of course. It probably doesn't matter much for one-sies and two-sies. But for repeated concatenations, it can be tremendous.

So it can be worth it to find places where using varying variables can be done. One thing to do is use procedures, then add the OPTIONS(*TRIM) on parameters, if they are CONST or VALUE. And make the parameter varying.

Again, where to do this depends on the situation. And be careful when mixing fixed and varying, as already mentioned.

HTH
Vern

On 2/22/2013 1:28 PM, Vernon Hamberg wrote:
Agreed - the example was meant to give the basic idea. In the case where
it really mattered, I was building HTML strings - yeah, I know - use
CGIDEV2 with externalized HTML But that was later.

The other caveat that I presented was populating varying fields with
data from fixed fields - very quick gotchas can occur there.

Vern

On 2/22/2013 12:24 PM, DeLong, Eric wrote:
Hmm, just an observation...

I think the NORMAL pattern of use in the case where you're concatenating a bunch of fields together is:

myString += %trim( theSalutation ) + ' ' +
%trim( theFirstName ) + ' ' +
%trim( theLastName );

Unless the shop standard is to use ONLY varying length values, using %trim() to strip down your field data PRIOR to append and specifically embedding blank characters where appropriate ensures that your formatted string will literally look as you want.

Even this would have issues if theSalutation was blank... The correction for that is another %trim, unfortunately...

myString += %trim( %trim( theSalutation ) + ' ' +
%trim( theFirstName ) + ' ' +
%trim( theLastName ) );

We NEVER want to ASSUME that blanks in data fields will be consistent...

-Eric DeLong

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Friday, February 22, 2013 12:10 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: simple problem with string handling

Hi Booth

I think you'd want that - except for only one blank in 'Mr ' - trailing
blanks in a literal are part of the string, even though it is processed
as a varying length, basically.

Vern

On 2/22/2013 11:37 AM, Booth Martin wrote:
If one wanted "Mr Vernon Hamberg" instead of "MrVernon Hamberg", would
one want:

webDta += "Mr " + varyingLengthVar;

?


On 2/22/2013 10:07 AM, Vernon Hamberg wrote:
Dale

Very cool.

Just as a reminder, when you concatenate varying length values, you
don't need the %trim at all. So you have this -

webDta += varyingLengthVar;

instead of -

webDta += %trim(varyingLengthVar);

It's a wonderful new world of RPG, eh?

Vern

On 2/22/2013 9:09 AM, dale janus wrote:
Varying-length variables will perform better than fixed-length ones,
Vern,

Thanks for the info on varying length being easier than it seems.


I can see future use of varying for creating HTML strings as you
indicated. Right now the few times we need to do it are in CL (which can
get ugly)


But I will keep your ideas in mind when we get to the rpg stage.

---Dale


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.