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

replace one word with another word

Status
Not open for further replies.

friend01

Programmer
Jun 4, 2009
94
0
0
CA
Hi All,

I have a .DBF with over 4 million records with 2 fields:
1 field = Memo Field called "SRC1".
1 field = Character field called "TYP"

I need to 'look' in every record in the field called "SRC1" and replace the word "Outbound" with the word "Inbound" for TYP$"3003*3007".

Any suggestions of how to code efficiently? Please let me know.


Thanks,
F1
 
I forgot to mention that the word "Outbound" cal be anywhere in the memo field and that I need to keep the text which is around it. Example, if the Memo field now contains:
"Regan Road_555/555-1234 Outbound Calls", I need it to say:
"Regan Road_555/555-1234 Inbound Calls". Another example, if the Memo field now contains:
"Outbound Calls for Jack Tripper", I need it to say:
"Inbound Calls for Jack Tripper". Just thought I'd mention that as I know it makes a difference. :)

Thanks again,
F1
 
Have you looked at the STRTRAN() function in your VFP Help?

REPLACE ALL SRC1 WITH STRTRAN(SRC1,"Outbound","Inbound");
FOR TYP $ "3003,3007"

Good Luck,
JRB-Bldr
 
Hi Friend01,

JRB-Bldr has given you the correct answer, but don't expect it be quick. TYP$"3003*3007" is not optimisable, and so your code will have to look inside both memo fields in every one of those 4 million records.

There's no way to avoid that delay given your existing table structure. You might need to re-think how you organise your data.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
thanks guys. I'll give it a try. apprecaite it. :)
 
If TYP is a 4-character field and you're just looking for the occurrence of either 3003 or 3007, then it would be faster to say

FOR TYP = '3003' OR TYP = '3007'

rather than

FOR TYP $ "3003*3007
 
jimstarr,

Absolutely right. It does make things quickrer.


Thanks
f1
 
You can also use the expression:
Code:
 at([3000],memofieldname)>0
for evaluating inside the memo field and only work those that contain the desired data
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top