Subject Re: strip_chars function in a loop
From Charlie <tm@tc.com>
Date Wed, 01 May 2024 17:15:52 -0400
Newsgroups dbase.getting-started

Thanks Mervyn.   works great.  I never got strip_specials, you gave me an example of strip_chars which i am using as a function.  

I never did much with scan, but it works well.  probably will use it a lot more from now on!

Thanks again!

Mervyn Bick Wrote:

> On 2024/05/01 16:49, Charlie wrote:
> > Hey Mervyn..  I am trying to use your function in a loop on a field called mintage which has large numbers with commas.  It is a character field with numbers.   I am trying to eliminate the commas after successfully appending into a new table.  Everything works fine as far as appending the field, but when I try to loop it this way it just replaces with the same chatacter all the way through.  Here is some code of things I've tried.  The function is the same except I changed the cToStrip = ",".  possibly that is the problem.  Any ideas on this?  Here is my code:
> >
> > use csvconv.dbf
> >         append from collection.dbf for csvt = true
> >         go top
> >         //do while not eof()
> >            //msgbox( ""+ '"'+trim(mintage)+'"' )
> >        //cStr = '"'+trim(mintage)+'"'
> >                 cStr = mintage
> >                 cNewStr = strip_chars(cStr)
> >                 replace mintage with cNewStr
> >         //        skip
> >         //enddo
> >         use
> >
> > As you can see I have tried different combinations.  Thanks for any help!
>
> The function strip_chars was in the program strip_specials.prg.  It was
> created specifically to strip & and # from some text.  The code was
> written so that if you wanted to strip & or # you only had to provide a
> single parameter namely the string to be manipulated.  To make the code
> a bit more universal provision was, however made for a second parameter
> to be passed if you ever wanted to strip something other than & or #.
> You do, however, need to pass that second parameter.
>
> I'm assuming that you have strip_specials.prg in the folder you are
> working in.  If not, add a path to strip_specials.prg in the code below.
>
> Seeing that you are working in XDML, keep in mind that you can use
> scan...endscan instead of a do loop with skip to loop through the table.
>   Makes life simpler. :-)
>
> use csvconv.dbf
> append from collection.dbf for csvt = true
> go top
> set procedure to strip_specials.prg // Add the path if necessary.
> scan
>    replace mintage with strip_chars(mintage,",")
> endscan
> use
>
> Mervyn.
>
>