Subject Re: find and delete within one field
From Charlie <tm@tc.com>
Date Tue, 12 Mar 2019 16:34:20 -0400
Newsgroups dbase.getting-started

Thanks again Mervyn!!

Mervyn Bick Wrote:

> On 2019-03-10 9:02 PM, Charlie wrote:
> > Hi... I would like to find all comma's in a particular field and delete them.   How can this be done?
> >
>
> A little example is attached.
>
> Mervyn.
>
>
>
> if file('remove_commas.dbf')
>  drop table remove_commas
> endif
>
> if not file('remove_commas.dbf')
>    create table remove_commas  (id autoinc,data character(35))
>    insert into remove_commas  (data) values ("dsf, gfghfh,  erertet, ertert")
>    insert into remove_commas  (data) values ("ertert, ererert, rtyry,erer, fghfgh")
>    insert into remove_commas  (data) values ("qweqwe, wwerwer ,,,werwre, ertet")
> endif
> clear
> use remove_commas
> list off all
> use
> ?
> q = new query()
> q.sql = 'select * from remove_commas'
> q.active = true
> do while not q.rowset.endofset
>   q.rowset.fields['data'].value = remove_commas(q.rowset.fields['data'].value)
>   q.rowset.next()
> enddo
> q.active = false
> use remove_commas
> list off all
> use
>
> Function remove_commas(cStr)
>    do while ','$cStr
>       cStr = stuff(cStr,at(',',cStr),1,'')
>    enddo
   return cStr