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 derfloh 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 Text in a Collection of Programs

Status
Not open for further replies.

SSDESIGN

Programmer
May 11, 2003
71
US
A large number of text strings have been hard coded into 96 procedures used in a project. Using the list of procedures in the project DBF, I would like to scan all of procedures replacing a given character string with a second character string.

In EDIT, you can select a procedure and do a find and replace within one procedure. However, there are 96 procedures with more than 57 strings to be replaced....

I have looked at processing the procedures at a low level - FOPEN, etc - without luck. I'm now looking at opening each procedure in a memo, search for and replace each string, and then saving as a prg. Would this mess up the format of the prg?

Is there a better way of doing this? I’m sure this is not unique.

Thanks for the assistance in advance...
You guys have been great in the past.
 
[ ]
I have modified programs in the past by opening up the project files, though I don't remember exactly what I did. And I am not where I can do any research to tell you exactly what to do.

MAKE A COMPLETE COPY OF YOUR PROJECT, then open up the various project files and experiment. If I remember correctly, I had to change some of the file extensions in order to view the contents. At worst you will get nowhere and will need to restore the project from your backup copies.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
Notepad will do this with its search and replace capability just like Foxpro's native text(program) editor, if the original string you wish to replace is reasonably unique. You will get into trouble if the original is a say a short string like "ST" which will turn up often as part of Foxpro reserved words eg STORE, STR
 
NotePad++ will let you open multiple text files and run a search and replace across all open files. You'd have to open the files in NotePad++ manually but you can do this by dragging groups of files so it shouldn't be too long a job.

Geoff Franklin
 
As prg files are simply text files you could use a newer foxpro version to make a search and replace across all files. VFP9 has code reference, I think it was introduced in VFP8. Then there are other search&replace tools for foxpro: Gofish for example should be available from uiversal thread.

It's quite easy to do something with FILETOSTR(), STRTRAN() and STRTOFILE(). Don't know if that are available functions in fox 2.6, though.

The best thing would be not to replace the strings with other strings, but define constants in an .h file and replace strings with the constant names. Then string changes could be done in the .h (header) file in a central place once for all occurances.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top