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