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



Very Cool Mel...

If it is always numbers, below is a 'de-formatting' routine I wrote to strip
all text characters out of a string and return the number... I use it so
that the user can enter phone numbers, Social Security Numbers, zipcodes,
etc. in any format and all I store in the DB is the number itself.  #CtoN is
a Character to Numeric, so you could replace it with 'atoi'.  It may not be
the cleanest but it is functional.

Joel

>-----Original Message-----
>From: Mel Rothman [mailto:mel@rothmanweb.com]
>Sent: Thursday, December 20, 2001 9:32 AM
>To: rpg400-l@midrange.com
>Subject: Re: Deleting blanks in a field
>
>An RPG IV approach:
>
>/free
>  fieldb = %triml(fielda);
>  i = %scan(' ':%trimr(fieldb));
>  dow i > 0;
>   fieldb = %replace('':fieldb:i:1);
>   i = %scan(' ':%trimr(fieldb):i);
>  enddo;
>  *inlr = *on;
>
>Mel Rothman



     H NOMAIN
      *--------------------------------------------------------------------
      * (#StripNum) Takes a character string and returns only embedded #s
      *             only returns Integers
      *
      * To Use: #StripNum(Character field to convert)
      *--------------------------------------------------------------------
      /COPY servicelib/qrpglesrc,pr_strip
      /COPY servicelib/qrpglesrc,pr_cton
      *--------------------------------------------------------------------
     P #StripNum       B                   EXPORT

      *--------------------------------------------------------------------
     d #StripNum       PI            30P 0
     d  Char                         30    VALUE

     d in              S              1    dim(30)
     d out             S                   like(in) dim(%elem(in))

     d  WrkChar        S             30
     d  WrkNum         S             30P 0
     d  i              S              2  0 inz(0)
     d  j              S              2  0

     d  numbers        C                   CONST('0123456789')
      *--------------------------------------------------------------------
     c                   eval      Char = %triml(Char)

     c                   movea     Char          in
     c                   eval      j = 1

     c                   for       i=1 to 30
     c                   testn                   in(i)                75
     c                   if        *in75 = *on
     c                   eval      out(j) = in(i)
     c                   eval      j = j + 1
     c                   endif
     c                   endfor

     c                   movea     out           wrkChar
     c                   eval      wrkNum = #CtoN(wrkChar)

     c                   Return    WrkNum
      *--------------------------------------------------------------------
     P #StripNum       E


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.