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




On Thu, 20 Dec 2001 bmorris@ca.ibm.com wrote:
>
> >From: Scott Klement <klemscot@klements.com>
> >
> >Here's a quick one I wrote (in the last 3 minutes) that will do what
> >you're asking:
> >
> >     P NoBlanks        B
> >     D NoBlanks        PI         32766A   varying
> >     D   Input                    32766A   const varying
> >     D Output          S            256A   varying
> >     D X               S             10I 0
> >     c                   eval      %len(Output) = 0
> >     c                   for       x = 1 to %len(Input)
> >     c                   if        %subst(Input:X:1)<>' '
> >     c                   eval      output = output + %subst(Input:X:1)
> >     c                   endif
> >     c                   endfor
> >     c                   return    output
> >     P                 E
>
> Scott, you beat me to it.  I looked at the scan and replace
> suggestions and thought a %subst and concatenate to a varying
> string would be better.  It is - it performs 5 times faster than
> Mel's %scan/%replace method.
>
> But only if the string being built up is varying.  Concatenation
> to the end of a varying string is very fast.
>
> Using %replace over and over requires a lot of extra copying of
> data.
>

Yeah, I saw two types of routines showing up.  The %scan/%replace was one
type, the other was using RPG III arrays. :)

Since both of these methods made me shudder, I posted my own :)

Incidentally, if I weren't using varying fields I'd assign to the output
string by doing

             %subst(output:y:1) = %subst(input:x:1)

to avoid the extra overhead of all the %trim()s needed with non-varying
fields.   But varying is much better :)  I'm sooo glad I'm not stuck at
V3R2 anymore...






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.