>>i need to replace several lines of code with a single line of code in about 300 forms and programs, which is the best way to do this?
>
>If you use a form as a table, as in Use MyForm.scx, you can then browse it. It has several records, for all the objects, etc. of the form. Each record has a "Methods" field in which you can find the code.
>
>You could write a wee prog to do the following:
>
>Get together an array of all your forms, using ADIR()
>Go through the array, opening each form as a table
> For each table:
> Scan through each rec, testing the methods field (memo) for and replacing the bit of code
> Don't forget to close the table (USE )
If forms are scattered in diferent subdirectories along development path or all over harddisc, then XDIR tool might help to simplify this process by retrieving all forms found along given path.
Download#
25487set procedure to ...\xdir.prg additive
local oDir
oDir=createobject('xRetrieve_all_scx')
oDir.xScan('C:\VFPDevelopmentPath')
oDir.xScan('C:\')
define class xRetrieve_all_scx as xdirectory
procedure with_directory
lparameters cPath
wait wind 'Now Searching ... ' + chr(13) + cPath nowait
procedure with_file
lparameters cFile,nSize,dLastMod,cTime,cAttr
if justext(cFile)='SCX'
=SearchAndReplaceInScx(cFile)
endif
enddefine
function SearchAndReplaceInScx
lparameters cScxFile
use (cScxFile) in 0 exclusive alias cMyForm
select cMyForm
.
locate ...
.
replace ...
.
use
return lFoundDoneOrNot
All that need to be done is to build & test function that does the job on a single form and simply plug that code instead of decriptive code I provided in function above.
This way everything can be done in one go versus applying procedure
for each directory containing forms.
I just might add this as new subclass/functionality to xdir download :))