Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace code...
Message
From
09/10/2000 22:06:51
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00427098
Message ID:
00427125
Views:
14
>How can you do Find and Replace code in Visual Fox Pro for the entire application, not just the current form you are editing? I need to change a hard coded drive "USE C:\FOXTEMP\FILENAME.DBF" to a replacable code "USE C:\FOXTEMP\&FILE" throughout the entire application and don't know how to do it.
>

Is this in .PRG files only? If so, then you can use ADIR() to collect the list of files, and use FILETOSTR(), STRTRAN() and STRTOFILE() to convert the files. You may find that you want to use a regular expression for matching purposes, to generalize the search; something like:
oReg = CREATEOBJ('Vbscript.RegExp')
oReg.Global = .t.
oReg.IgnoreCase = .t.
oReg.Pattern = '\s+(C:[\w\\]*\\)(\w*)\.DBF'
n=ADIR(aFiles,'*.PRG')
FOR i = 1 TO n
   cStr = FILETOSTR(aFiles[i,1])
   cStr = oReg.Replace(cStr,'("$1file")')
   ? STRTOFILE(cStr,aFiles[i,1])
ENDFOR
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform