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

Replacing a character string through a whole project

Status
Not open for further replies.

tmaycroft

IS-IT--Management
May 9, 2002
9
0
0
US
I have a project written in VFP 7.0. I need to do a find and replace for "XXXXX" to "YYYYY" throughtout the entire project. The project has forms, menus and prgs.

Basically the company name is hard coded into some of the code and we have a company name change.

Any help would be appreciated.

 
If you have a copy of VFP 8 around you should be able to open the project with 8 and use the code references tool to search and replace. Then rebuild back in 7.

Mike Reigler
Melange Computer Services, Inc
 
In VFP 8.0, you would use the Code References tool.

As you have 7.0, your best bet would be to look for a copy of Steve Dingle's Project Search tool. It used to be at but Steve's re-organised his sites and I'm not sure where it is now. You could always try Google.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

Well, I didn't know you could do it with Code References tool in VFP8, since I still use VFP6; so I put together the response below. I still decided to post it, just in case it would help you or someone else.

=========

Before you start replacing, make sure that you don't have to do it ever again when company name changes again. Create a variable, or object with a property holding that name, or create a table and read from it. You can do so to some other hard-coded stuff while you are at it. Now you will need to replace your "XXXXX" not with "YYYYY", but with your variable/object.property name.

For your PRGs, you can probably create a simple algorithm that uses ADIR() function to get names of all the .PRG files from you directory into an array and loop through them. Inside the loop, you can back up each file, send it into a string with FileToStr() function, modify it using STRTRAN() function, and send back to the file with StrToFile() function.

If you also have it in the forms and classes, you probably can open your project file as a table (you can do the same for the tables, too) and SCAN it for the names; back up each, then open each as a table, too, and scan appropriate memo fields for the string in question, change them with STRTRAN() and replace back.

You can also take a look at faq184-4392. It writes all methods from all forms and classes included in the open project to a text file, but you can probably tweak the code to edit all methods of forms and classes instead.

 
Having been down this route before. Might I suggest that this time you replace with with a global variable reference, like gccompanyname.

I have a project that has gone through 5 name changes. It only took me 2 to figure that out.

 
Another handy free search/replace tool is GOFISH.PRG. It allows you to do an entire directory structure or a project, and exclude any file type. It also has global replace capability. Google it to find where to download.



Mike Krausnick
Dublin, California
 
What about using the old "FILER" application that was in older versions of foxpro.

It still works perfectly with VFP 6. Will allow you to find all the files and either do a global replace within each or make specific changes. Note you can only edit .prg files, but it will give you accurate lists of forms and reports that contain the search screen and you can open them individually to change.

Not fancy, but it works.
 

Tmaycroft,

You started this thread two weeks ago, and have had several useful suggestions, but you haven't taken the trouble to reply to any. It would be helpful if you could respond -- or at least to have the courtesy to acknowledge them.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

I cant speak for tmaycroft but I have to say that this thread is most instructive. I've been using vpf8 for a little more than a year and I did not know about the code reference tool, nor did I know about the third party solutions available for this.

Thanks to all

Jean
 

Jean,

I'm pleased you've found this thread useful. I have as well. It's always nice to see different solutions and different perspectives on an issue.

But I do think it's discourteous when someone posts a question, and then never bothers to come back to look at the replies or acknowledge them in any way. Maybe I'm just being over-sensitive.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

Feedback is the only reward people get from their efforts in trying to help others in this forum. I fully agree with you. BTW thanks for your presence on this forum. Your knowledge and insights are much appreciated.



Jean
 
Mike and Jean

I agree with your comments and in particular Mikes:
You started this thread two weeks ago, and have had several useful suggestions, but you haven't taken the trouble to reply to any. It would be helpful if you could respond -- or at least to have the courtesy to acknowledge them.
Very recently, I had some very beneficial advice given in this forum that I'm sure I would have been lost without it. The result posted on the thread benefits everyone. A reply would be useful for others.

Let me just say for my past experience, thanks again guys....

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top