Need Help: search/replace data in one field/one record, by queries or script: PDOX5

Need Help: search/replace data in one field/one record, by queries or script: PDOX5

Post by Guy Nort » Wed, 03 Apr 1996 04:00:00



I am trying to change all the data in one field and move it on the
left.

I am giving you a practical example.

I am classifying the files on one of my hard drive.
The file is called   GUYTEST.ZIP
What I am trying to do is to remove that dot between GUYTEST and
ZIp and to rewrite it like this GUYTEST ZIP.

Look simple but this is not easy.

I have looked at IMPORTING/EXPORTING and I have spent hours.


or indicate where I can find some on line documentation

Any help appreciated

Thanks  

 
 
 

Need Help: search/replace data in one field/one record, by queries or script: PDOX5

Post by Bob Barro » Thu, 04 Apr 1996 04:00:00


I'm not sure I completely understand your problem, but I'll take a stab at
it.
Assuming you have a field containing GUYTEST.ZIP, and nothing else, you can
use breakapart() to break the string defined as GUYTEST.ZIP apart at the
period and store the results in an array which, in this case will have two
elements: array[1] will be GUYTEST and array[2] will be ZIP. Now just use
string concatenation to rewrite the array elements into a string variable
(strvar=ar[1]+ar[2]+".") and then define the field as the new string. Use a
scan loop to perform this on all the records in your table. Just be careful
if this is a key field Read the online help about scan loops and string
variables (and toss in a little reading about arrays <G>).

The problem is a little tougher if the field contains sentences or
paragraphs with multiple occurrences of GUYTEST.ZIP. One technique would be
to use tcursor.locate("fieldname","GUYTEST.ZIP") combined with a while loop
to get to all records containing GUYTEST.ZIP.
while tcursor.locate("fieldname","GUYTEST.ZIP")
        strvar=tc."fieldname"
        strvar.breakapart(array,"GUYTEST.ZIP") ; breaks it at GUYTEST.ZIP
        strvar.blank()
        for x from 1 to array.size() step 2
                strvar=strvar+array[x]+"GUYTESTZIP."+ar[x+1]
        endfor
        tcursor.edit()
        tcursor."fieldname"=strvar
        tcursor.postrecord()
endwhile

The usual disclaimer <g>: This is untested, off-the-top-of-my-head code.
You may have to tinker with it to get it to work. Hopefully, you will go to
the relevant sections of the online help and maybe come up with a better
way to do this. If you do, I'd be very interested in seeing it.

Hope this helps
Bob Barrows