Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search replace in all forms
Message
From
05/07/2006 04:20:47
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01133601
Message ID:
01133745
Views:
11
>>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#25487
set procedure to ...\xdir.prg additive

local oDir
oDir=createobject('xRetrieve_all_scx')

oDir.xScan('C:\VFPDevelopmentPath')
*or
oDir.xScan('C:\') &&for entire drive



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)  &&Do single form            
        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 :))
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform