Subject Re: strip_chars function in a loop
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 1 May 2024 17:33:15 +0200
Newsgroups dbase.getting-started

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.
   replace mintage with strip_chars(mintage,",")


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0