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!

how to selectively replace text in a field 1

Status
Not open for further replies.

joetrogdon

Technical User
Feb 20, 2004
4
US
I have a database that has a field labeled descript which contains descriptions of products. The current fields look like this:

10 7/8 x 14 1/4 + flap, crystal clear (232 x 324)

I would like to leave the dimensions in the beginning, but change the rest to just say "Archival Plastic Bag", so essentially it would now read:

10 7/8 x 14 1/4 Archival Plastic Bag

I understand how to swap out all the data in the field, I was just unsure if I could do it selectively or exclude all numeric characters outside of (). Sorry I don't have any code for you to use, as I said I don't know where to begin.

Thanks in advance.

 
Joe,
Can you give a few more examples? Are you always going to put "Archival Plastic Bag" after the initial numeric dimensions? Or is there a "conversion" list of old descriptions to new descriptions?

Is this a one time conversion? Or do you need to do this for an on going process? How many records?

Rick


 
It may be better to do a replace at a certain position in the field.
Like if the description is going to be at offset 17.
If not, you may need to look for a common character such as the "+" sign after the size:

If at same position:
Code:
STORE "Archival Plastic Bag" TO cNewDescript  
   &&... or however you obtain new description for above line
REPLACE descript WITH LEFT(descript, 17) + cNewDescript
If using common char like "+"
Code:
REPLACE descript WITH LEFT(descript, AT(descript, "+")) + ;
   cNewDescript


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Dave,

Thanks a lot, that works great for doing it at the same position. However I realize that I need to do it with a commom character, like the +, but when I use the code you gave it deletes the entire description and inserts the newdescript.

My code is as follows:

USE e:\ceonline\testdata\inventor.dbf in 1

cNewDescrip = "Archival Plastic Bags"

REPLACE FOR SKU = "BAGS" descrip WITH LEFT(descrip, AT(descrip, "+")) + cNewDescrip

If you haven't guessed I'm not a programmer, our resident code guy is gone and I'm doing my best to fill in :p. Thanks for the help.

Joe
 
Sorry, big booboo. I do that about half the time (get the parameters backwards).
That last one should read
If using common char like "+"
Code:
REPLACE descript WITH LEFT(descript, AT([COLOR=red]"+", descript[/color])) + ;
   cNewDescript


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top