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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dBASE - replace PA with NJ in Text Field

Status
Not open for further replies.

jwkolker

Programmer
Jan 9, 2003
68
US
Hello:

I am looking for a quick .prg that will change text within a field example:

1234 Your Street, YourTown, PA

Want to change it to:

1234 Your Street, Yourtown, NJ...

Want to step through all records in all fields and find a value and replace it.

Please help me.

Thanks.

John Kolker

John Kolker
Programmer
jwkolker@comcast.net
 
Hi

I take it that the value you want to replace is in a random position within that field?

If that is the case, you are going to have to build a program that:

a) identifies the record with the value
b) find out where that value is in the field
c) use the STUFF function to along with the REPLACE command

e.g.

USE YourTable

cSearch = "NJ"
cReplace = "AZ"

nPos = 0

do while .not. eof()
if cSearch $ surname
nPos = AT(cSearch,MyField)
REPLACE SURNAME WITH STUFF(MyField,nPos,2,cReplace)
endif
skip
enddo

* where MyField is the name of the field

NOTE:

This is not case sensitive and there is no prompting to change, it will just do it, but you shopuld get the gist of it.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top