Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting occurrences of variable in a project
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01629312
Message ID:
01629319
Views:
56
Likes (1)
*A project file is a table that keeps track of all the source files such as programs, forms, menus, libraries,
* reports, labels, tables, indexes, and format files. A project also keeps track of all the dependencies,
*references, and connections among the files.(foxHelp)
*this code can search for any string in a project and retrieve all results (can work for a variable name for sure).
*the better way is to declare variable as local,vfp release it automatically and not to fear the repetition along the codes.

Clea All
Close All
Close Data All

local m.lcproj
m.lcProj= Getfile('pjx')
if empty(m.lcProj)
return .f.
endi 

Modify Project (m.lcproj) Noshow Nowait
Local N,myvar,x,cr,xx,yy,i
#Define cr  Chr(13)
m.n=0
m.x=""
m.yy=""
m.myvar="do"   &&any  string to search a variable name)
i=0
For Each oFile In _vfp.ActiveProject.Files
	m.xx=Occurs(m.myvar,Filetostr(oFile.Name))
	m.n=m.n+m.xx
	If m.xx>0
		m.x=m.x+Trans(m.xx)+" in file:"+oFile.Name+cr
	Endi
	i=i+1
	m.yy=m.yy+Trans(i)+" - "+oFile.Name+cr
Next


TEXT to m.my textmerge noshow
-files count=<<trans( _VFP.ActiveProject.files.count)>>  in  project: <<_vfp.activeProject.name>>

<<trans(m.n)>>  occurences of  string [<<m.myvar>>] found in <<_VFP.ActiveProject.name>> as follow:

<<m.x>>

-<<_vfp.activeProject.name>> :All project files enumeration:
<<m.yy>>
ENDTEXT
Local m.lcdest
m.lcdest=Addbs(Sys(2023))+"asup.txt"
Strtofile(m.my,m.lcdest)
Run/N notepad &lcdest

_vfp.ActiveProject.Close
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform