Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Similar problem I am sure...
Message
General information
Forum:
Visual FoxPro
Category:
Project manager
Miscellaneous
Thread ID:
00450068
Message ID:
00450873
Views:
32
Here's a little code that checks all of the sub-folders for files and sees if they are already in the project. It assumes a tree structure with the project in the root, and everything else in sub-folders, but you can tweak it... These routines we cut out of a .vcx, so you'll see references to 'This.'

mike

parameters tnBuildNew
local loP, loFile
local lcErrs
private pcExtensions

if !type("Application.ActiveProject")='O'
modify project ? nowait
endif
if !type("Application.ActiveProject")='O'
return
endif

loP=Application.ActiveProject
cd (loP.HomeDir)

lcErrs=''
pcExtensions='|VCX|FRX|SCX|ICO|BMP|CUR|MNX|PRG|FLL|H|'
if vartype(tnBuildNew)<>'N'
tnBuildNew=0
endif

wait window nowait noclear 'Gathering List of Local Files...'
create cursor csrLclFiles (filename C(40), filepath C(200))
This.Folder_Drill_Down(sys(5)+curdir()) &&fills cursor with files from hard disk
index on filename tag filename
index on filepath+filename tag filepath

cd (loP.HomeDir)

wait window nowait noclear 'Checking To See That Each File Is In the Project...'
set order to filepath
go top
scan
if type("loP.Files(alltrim(filepath)+alltrim(filename))")<>'O'
if tnBuildNew>0 or;
messagebox("Local file was not found in project:"+chr(13)+chr(10)+;
alltrim(filepath)+alltrim(filename)+chr(13)+chr(10)+chr(13)+chr(10)+;
"Add it now?", 4+16, "Possible New File")=6
loFile=loP.Files.Add(alltrim(filepath)+alltrim(filename))
if vartype(loFile)<>'O'
lcErrs=lcErrs+'Add File To Project Failed: '+;
alltrim(filepath)+alltrim(filename)+chr(13)+chr(10)
endif
if '_RELEASE.TXT' $ upper(alltrim(filename))
loFile.exclude=.t.
endif
endif
endif
endscan

wait clear
if !empty(lcErrs)
messagebox(lcErrs,0,'ERRORS OCCURRED')
endif


********* RECURSIVE PROCEDURE ************
** fills a cursor with files in all sub-folders
lparameters lcInDir
local laDirs, laFiles, lnI, lnJ

dimension laDirs[1], laFiles[1]

cd (lcInDir)
for lnI=3 to adir(laDirs, '', 'D') &&recurse through folders
This.Folder_Drill_Down(addbs(lcInDir)+laDirs[lnI,1])
endfor
cd (lcInDir)

&&rule is that the main folder doesn't get processed
if upper(addbs(lcInDir))==upper(addbs(Application.ActiveProject.HomeDir))
&&in root folder only add release.txt and config.fpw if found - nothing else
if adir(laReleaseText,'*_RELEASE.TXT')>0
insert into csrLclFiles;
(filename, filepath);
values;
(laReleaseText[1,1], sys(5)+curdir())
endif
if file(sys(5)+curdir()+'CONFIG.FPW')
insert into csrLclFiles;
(filename, filepath);
values;
('CONFIG.FPW', sys(5)+curdir())
endif
else
for lnJ=1 to adir(laFiles) &&process files
if '|'+upper(justext(laFiles[lnJ,1]))+'|' $ pcExtensions
insert into csrLclFiles;
(filename, filepath);
values;
(upper(juststem(laFiles[lnJ,1]))+'.'+upper(justext(laFiles[lnJ,1])),;
upper(sys(5)+curdir()))
endif
endfor
endif
Previous
Reply
Map
View

Click here to load this message in the networking platform