Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and replace

Status
Not open for further replies.

brownw

MIS
Jun 4, 2000
6
US
I have a table with one of its fields called EmpName. This field has the employee last name, first name and middle initial. The last name and first name are separated by a comma. I would like to read each record in my table and replace the comma in the EmpName field with a space. Here is the script I composed to do this job however, it is not working. I would appreciate any suggestions on how to correct this script.

---------------------------------------------------------------------------------------------------
method run(var eventInfo Event)

var

tc TCursor
ar Array[3] String ;AnyType
s, news String

endvar

tc.open("Empaddress2.DB")
tc.edit()
ar.setSize(3)
scan
tc for tc.&quot;FIELD005&quot; <> &quot; &quot;:
s = tc.&quot;FIELD005&quot;
s.breakApart(ar, &quot;,&quot;) ; breaks on commas
news = ar[1] + ar[2]
tc.&quot;FIELD005&quot; = news

endscan

tc.endedit()
tc.close()

endMethod

---------------------------------------------------------------------------------------------------

Thanks,

Wilbert Brown
 
Wilbert,

just some small changes to your code:

var
tc TCursor
ar Array[] String
s, news String

endvar

tc.open(&quot;Empaddress2.DB&quot;)
tc.edit()

scan tc for not tc.&quot;FIELD005&quot;.isBlank():
s = tc.&quot;FIELD005&quot;
s.breakApart(ar, &quot;,&quot;)
if ar.size() = 2
then
news = ar[1] +&quot; &quot;+ar[2]
tc.&quot;FIELD005&quot; = news
endIf
endscan

tc.endedit()
tc.close()

hope this works for you
regards
hans schoutsen
 
Thanks hans, your script worked just fine.

Wilbert Brown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top