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



Hi Aaron,
Obviously %TRIM() is more expensive that %TRIMR or %TRIML alone.
Thus you should always use only the one you really need. I do see a lot of code
that uses %TRIM() exclusively and that's expensive, relatively speaking.
%SUBST also used to be expensive but I believe it was enhanced and now works
pretty well in most cases. 
%LEN(xxx) is very efficient because it just looks at the hidden 5u0 prefix to
check the field's current length. 

%LEN(x) = %len(%Trim(x)) is just wrong.
Think about this:

 X = "  BOB COZZI  "
 %Len(x) = %Len(%Trim(x)) 
Sets the length of X to 9.
So X now equals:

X = "  BOB COZ"


-Bob Cozzi
www.iSeriesTV.com
iPod your industry news instead of reading it.
Coming June 2006
Ask your friends to tune into iSeriesTV.com

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of albartell
Sent: Monday, June 05, 2006 7:37 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: My dilemma with VARYING was ->RE: Error in %trim BIF with V5R3?

So my next question is obviously going to be... 

Is this...

If (%len(var) > 0) and ((%subst(var): %len(var): 1) = ' ');

...less or more expensive than doing this...

%len(var) = %len(%trim(var));

... in the first place?

Or maybe better stated: What type of "iterations" is %trim going through to
strip blanks?

Aaron Bartell
http://mowyourlawn.com/blog


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Joe Pluta
Sent: Monday, June 05, 2006 7:20 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: My dilemma with VARYING was ->RE: Error in %trim BIF with V5R3?

There's always the dilemma of defining and enforcing contracts.  If you
can't trust the people who call your procedures to do it correctly, then
either you aren't communicating those requirements correctly, or they're not
very good programmers.  Neither option bodes well for long term software
quality.

However, there is a sort of halfway position.  Just check the last position
of the passed string.  If it's blank, trim it.  I think something like this
will work:

If (%len(var) > 0) and ((%subst(var): %len(var): 1) = ' ');
  %len(var) = %len(%trim(var));
Endif;

Joe


From: albartell

CatPath += ('cat=' + %char(CatArr(i)) + '&');

I like using this syntax along with VARYING fields (for all of the 
obvious reasons), but the thing I struggle with is when I need to be 
ensured that something does not have trailing blanks (e.g. 
concatenating a IFS stream file path). This seems to be the case more 
often than not.  A lot (nearly
all) of my development is done with RPG ILE service program sub procs. 
So I am constantly providing interfaces to other programmers.  I am 
not so worried about them implementing the interface correct (i.e. 
using VARYING in their programs), but more so that they aren't 
ensuring the absence of blanks in strings before they pass them on to 
sub procs I create. Sure I could just insert a few more %TRIM's here 
and there to bullet proof my programs, but then I just lost some of 
the benefit I was trying to gain.


--
This is the RPG programming on the AS400 / 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.