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



Try this

d RemoveChars pr
d SourceString 32767 varying options(*varsize)
d CharsToRemove 256 varying value
d RemoveCharsSource...
d s 32767 varying

*----------------------------------------------------------+
* RemoveChars
*----------------------------------------------------------+
p RemoveChars b
d pi
d SourceString 32767 varying options(*varsize)
d CharsToRemove 256 varying value

d wRmvChrCounter s 10i 0
d wRmvChrChar s 1
d wRmvChrScanPos s 10i 0
d wRmvChrNotFnd s 1n
/free
for wRmvChrCounter = 1 to %len(CharsToRemove);

wRmvChrChar = %subst(CharsToRemove:wRmvChrCounter:1);
reset wRmvChrNotFnd;
dou wRmvChrNotFnd;
wRmvChrScanPos = %scan(wRmvChrChar:SourceString);
if wRmvChrScanPos = *zero;
wRmvChrNotFnd = *on;
iter;
endif;
SourceString = %replace('':SourceString:wRmvChrScanPos:1);
enddo;

endfor;
return;
/end-free
p e

Brgds

Helge

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Asher613Smith@xxxxxxx
Sent: Tuesday, September 09, 2008 11:44 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: New %Trim Function

Looks right. TRIM does trimming at the ends, not in the middle.

SO trimming 'x' in 'xxxabcxxxxyzxxx' would result in 'abcxxxxyz'.

Similarly, in early versions, trimming
' Last, First, Middle ' would give
'Last, First, Middle', not
'Last,First,Middle'


In a message dated 9/10/2008 12:37:04 A.M. Jerusalem Daylight Time,
rwmunday@xxxxxxxxxxxxx writes:

I have been testing the new %Trim second parameter featured in V5R4. I have
an application where I could trim stray period characters. The example I
was given from another programmer who uses this is blanks, `/` and `\`. I
wrote a test program and coded this:

// Trim To Remove The Listed Characters
TRIMOUT = %Trim(TRIMIN :' .\/'); // Trim Blank, Period, Slashes

I keyed some test data into a file and this was the result:

12 45\67/ 12 45\67 removed the trailing '/'
1/1\2 1/1\2 removed nothing
112 33\44\ 112 33\44 removed trailing '\'
///\1234.56 1234.56 removed all slashes
987.654 987.654 removed nothing


Something is working part of the time. I have been unable to locate an
example other than what was listed in the official announcement:

Second parameter for %TRIM, %TRIMR and %TRIML indicating what characters to
trim:
%TRIM is enhanced to allow an optional second parameter giving the list of
characters to be trimmed.

Assistance, please.

Thanks,



Robert Munday
Munday Software Consultants
Montgomery, AL
on assignment in Jacksonville, FL



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.