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!

Searching all program files for text

Status
Not open for further replies.

mike777

Programmer
Joined
Jun 3, 2000
Messages
387
Location
US
Hello.
I have been reading up on the Project and File objects. Specifically, the properties on the File object. I would like to be able to do a string search of all the programs in my project, so, for example, if I change a parameter in a [procedure file] function, I can search all of the project program files to see which ones are affected.
I doesn't readily appear to me that the File object has a property where I can read (or search) the code as text as I iterate through the list of program files, does it?
Do you have any other suggestions?
Thanking you in advance.
-Mike
 
mike777

You can load you whole project file in the class browser (change the option form class to project), and one of the option (at the menu bar the binoculars) to find any word in your whole project. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

you could even perform a simple seek from within Windows Explorer pointed to your app.

best regards and season's greeting from Belgium !

wilfredo
 
Hi

You can use the following.
1. Cut and paste the following code as gsCode.PRG
2. Open the project and run this from command window.
=GSCODE() or DO gsCode
3. You will get all the procedures in all forms in your project.. as a text file in the projects name.
4. You can now use the native seek command to locate the words or commands you want to search and identify the places.
5. Since I have my own code editor for forms, I have ceased using this tool developed earlier. However I just modified slightly and added the title/date code provided by Klaus.
6. Provided as freeware and Use at your own risk.
7. This only brings up the code collection.. but does not provide for modifications to the relevant forms.
*********************************************************
** Programe gsCode2
** Category : Development Tool
** This program will write all methods from all forms
* included in the open project
* to a text file with same name as project
** Since discontinued.. refer gsEdit for latest version
*********************************************************
** PROCEDURE gscode2
*
#DEFINE CRLF chr(13)+chr(10)

LOCAL cFormFile, cAlias, cSaveError, ;
cOutPut, cTitle, Date_time, cLine, cLine1, ;
nFiles, nCount, nLoc
CLOSE TABLES ALL
** Collect files from project
nFiles = application.ActiveProject.Files.Count
cOutPut = application.ActiveProject.Name+".txt"
cLine = REPLICATE("*",70)+CRLF
cLine1 = "** procedure end *"+REPLICATE("*",50)+CRLF
cTitle = "** Documentation of the forms in Project: " +JUSTSTEM(cOutPut)+CRLF
date_time = "** Date/Time: "+ TTOC(DATETIME())+CRLF

*Write the headers with formTitle+date+time
STRTOFILE("",cOutput,.F.) && Wipe existing file
STRTOFILE(cTitle,cOutPut,.T.)
STRTOFILE(date_time,cOutPut,.T.)
STRTOFILE(cLine,cOutPut,.T.)
STRTOFILE(CRLF+CRLF+CRLF,cOutPut,.T.)
**
FOR i = 1 TO nFiles
cFormFile = application.ActiveProject.Files(i).NAME
IF UPPER(JUSTEXT(cFormFile)) = "SCX"
** Now we can actually start
cAlias=JUSTSTEM(cFormFile)
nCount = 1
USE (cFormFile) IN 0 ALIAS (cALias)
SELECT (cAlias)
** Create a sub-title for the form
cTitle = "** FORM: " +cAlias+CRLF
STRTOFILE(cTitle,cOutPut,.T.)
STRTOFILE(cLine,cOutPut,.T.)
**
SCAN
* Look for Methods
DO WHILE .t.
nLoc=AT("PROCEDURE",UPPER(methods), nCount)
IF nLoc>0
cTemp=SUBSTR(methods,nLoc)
cTemp=LEFT(cTemp,AT("ENDPROC",cTemp)+7)
STRTOFILE(cAlias+ ;
" *** "+objname+CRLF+cTemp,cOutput,.T.)
STRTOFILE(cLine1,cOutPut,.T.)
STRTOFILE(CRLF+CRLF+CRLF,cOutPut,.T.)
ELSE
EXIT
ENDIF
ncount = nCount+1
ENDDO
nCount = 1
ENDSCAN
STRTOFILE(cLine,cOutPut,.T.)
STRTOFILE("** End of form procedures....: "+ ;
cAlias+CRLF,cOutPut,.T.)
STRTOFILE(cLine+cline+cline+cline+cline,cOutPut,.T.)
STRTOFILE(CRLF+CRLF+CRLF,cOutPut,.T.)
USE IN (cAlias)
ENDIF
ENDFOR
MODIFY FILE (cOutPut)
RETURN
*********************************************************
** EOF
*********************************************************
ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
Merry Christmas & Happy New Year [bigears] [party] [2thumbsup]

 
HI Mike...

Sorry.. the above takes care of Forms Procedures..
The following takes care of PRGS in a project..
*********************************************************
** Programe gsCode3
* This will consolidate all Prgs included in open project
* and open up editor window.
* Save to your convenience with a suitable file name.
*********************************************************
** PROCEDURE gscode3
*
#DEFINE CRLF chr(13)+chr(10)

LOCAL cPrgFile,cText,cOutPut,cTitle,Date_time,cLine,nFiles

** Collect files from project
nFiles = application.ActiveProject.Files.Count
cOutPut = SYS(3)+".txt"

cLine = REPLICATE("*",70)+CRLF

cTitle = "** Documentation of the PRGS in Project: " + ;
application.ActiveProject.Name+CRLF
date_time = "** Date/Time: "+ TTOC(DATETIME())+CRLF

*Write the headers with formTitle+date+time
STRTOFILE("",cOutput,.F.) && Wipe existing file
STRTOFILE(cTitle,cOutPut,.T.)
STRTOFILE(date_time,cOutPut,.T.)
STRTOFILE(cLine,cOutPut,.T.)
STRTOFILE(CRLF+CRLF+CRLF,cOutPut,.T.)
**

FOR i = 1 TO nFiles
cPrgFile = application.ActiveProject.Files(i).NAME
IF UPPER(JUSTEXT(cPrgFile)) = "PRG"
** Now we can actually start
cText=FILETOSTR(cPrgFile)
** Create a sub-title for the form
cTitle = "** PRG: " +cPrgFile+CRLF
STRTOFILE(cTitle,cOutPut,.T.)
STRTOFILE(cLine,cOutPut,.T.)
STRTOFILE(cText,cOutPut,.T.)
STRTOFILE(cLine,cOutPut,.T.)
STRTOFILE("** End of PRG.: "+cPrgFile+CRLF, ;
cOutPut,.T.)
STRTOFILE(cLine+cline+cline+cline+cline,cOutPut,.T.)
STRTOFILE(CRLF+CRLF+CRLF,cOutPut,.T.)
ENDIF
ENDFOR
MODIFY FILE (cOutPut)
STRTOFILE("",cOutput,.F.) && Wipe file created
RETURN
*********************************************************
** EOF
*********************************************************
ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
Merry Christmas & Happy New Year [bigears] [party] [2thumbsup]

 
Checkout:

thread184-353575

May be of help!

Neil "I love work. I can sit and stare at it for hours..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top