Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Utility to Copy Project and Create Sub Dir Tree?
Message
De
15/02/2002 11:01:10
 
 
À
15/02/2002 10:00:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00620588
Message ID:
00620693
Vues:
10
OOPS, I had to add copying the project files themselves:
*---Copyproject.prg
LPARAMETERS lcprojectname
#define    _END_CHAR         CHR(10)
#define    _NULL             CHR(0)
SET SAFeTY OFF
SET STATUS BAR ON
CLOSE ALL
CLEAR
IF UPPER(TYPE('lcprojectname')) ="L"
	lcprojectname=GETFILE("pjx")
ENDIF
IF UPPER(TYPE('lcprojectname'))="L" .or. EMPTY(lcprojectname)
	WAIT WINDOW "You must select a valid project!" NOWAIT
	RETURN
ENDIF
WAIT WINDOW TIMEOUT 1.5 "Copying project: "+lcprojectname
LOCAL lcsetdefault
lcsetdefault=UPPER(LEFT(lcprojectname,RAT("\",lcprojectname)))
SELE 1
USE (lcprojectname) EXCLU ALIAS myproj
GO TOP
LOCAL m.projold, m.projnew
m.projold=""
m.projnew=""
LOCAL m.cname
m.cname=""
LOCAL m.cpath
m.cpath=""
LOCAL m.cshort
m.cshort=""
LOCAL lnpos
lnpos=0
LOCAL m.cidx
m.cidx=""
LOCAL m.cext
m.cext=""
LOCAL lcdirectory
lcdirectory="\DEVUPDATES\"
LOCAL lcnewdir
lcnewdir=lcdirectory
LOCAL lcdefault
lcdefault=SYS(2003)
LOCAL llmakedir
llmakedir=.T.
LOCAL istop
istop=1
LOCAL i
i=1
LOCAL lndeleted
lndeleted=0
LOCAL lntot1
lntot1=RECCOUNT()
LOCAL lntot2
lntot2=0
set DEFAULT TO &lcsetdefault
DO WHILE !EOF(1)
	IF DELETED()
		lndeleted=lndeleted+1
		SKIP
		LOOP
	ENDIF
	*Strip out the path to the file
	istop=(LEN(myproj.name))
	FOR i = 1 TO (istop+1)
		IF  ASC(SUBSTR(myproj.name, i, 1)) = 0
			m.cname = LEFT(myproj.name, i -1)
			EXIT
		ENDIF
		IF i=LEN(myproj.name)
			EXIT
		ENDIF	
	ENDFOR	
	m.cpath=UPPER(LEFT(m.cname,RAT("\",m.cname)))
	lnpos=(RAT("\",m.cname)+1)	&& one position to the right of
	IF lnpos>0
		m.cshort = UPPER(SUBSTR(m.cname,lnpos))	&& grab from lnpos to end
	ELSE
		m.cshort=m.cname
	ENDIF
	m.cidx=UPPER(LEFT(m.cshort,RAT(".",m.cshort)-1))			&& strip off the extension
	m.cext=ALLTRIM(RIGHT(ALLTRIM(m.cshort),3))
	? "m.cname="+m.cname
	? "m.cpath="+m.cpath
	? "m.cshort="+m.cshort
	? "m.cidx="+m.cidx
	? "m.cext="+m.cext
	? "**********"
	IF UPPER(m.cext)="PJX" .and. llmakedir
		lcdirectory=lcdirectory+m.cidx
		lcnewdir=lcdirectory+"\"
		IF !DIRECTORY(lcdirectory)
			MD (lcdirectory)
		ENDIF
		IF FILE(lcnewdir+'projectlist.dbf')
			DELETE FILE (lcnewdir+'projectlist.dbf')
		ENDIF
		IF FILE(lcnewdir+'projectlist.cdx')
			DELETE FILE (lcnewdir+'projectlist.cdx')
		ENDIF
		SET DEFAULT TO &lcdirectory
		CREATE TABLE projectlist ;
   				(cname c(100), ;
   				cpath c(100),;
   				cshort c(30),;
   				cidx c(20),;
   				cext c(3))
		IF !USED('projectlist')
			USE projectlist IN 0 EXCLU ALIAS projectlist
		ENDIF
		SELE projectlist
		IF UPPER(ALLTRIM(ALIAS()))="PROJECTLIST"
			ZAP
			INDEX ON cname TAG cname
			set order to 0
		ENDIF
		llmakedir=.F.
		SET DEFAULT TO &lcsetdefault
	ENDIF	&& on the first record
	SELE projectlist
	IF UPPER(ALLTRIM(ALIAS()))="PROJECTLIST"
		APPEND BLANK
		GATHER MEMVAR MEMO
	ENDIF
	IF UPPER(ALLTRIM(m.cext))!="PJX" .and. LEFT(m.cname,5)!="..\.."
		IF !DIRECTORY(lcdirectory+"\"+m.cpath)
			MKDIR (lcdirectory+"\"+m.cpath)
		ENDIF
		=ADIR(lcsource, sys(2003)+"\"+m.cpath+m.cidx+".*")  && Create array
		FOR i = 1 TO ALEN(lcsource,1)
			IF FILE((lcdirectory+"\"+m.cpath+lcsource(i,1)))
				DELETE FILE ((lcdirectory+"\"+m.cpath+lcsource(i,1))
			ENDIF
			COPY FILE (sys(2003)+"\"+m.cpath+lcsource(i,1)) TO (lcdirectory+"\"+m.cpath+lcsource(i,1))
		ENDFOR
	ELSE
		IF UPPER(ALLTRIM(m.cext))="PJX"
			=ADIR(lcprojfiles, m.cpath+m.cidx+".*")  && Create array
			m.projold=m.cpath
			m.projnew=lcdirectory+"\"
		ENDIF
	ENDIF
	SELE myproj
	SKIP
ENDDO
USE IN myproj
SELE projectlist
lntot2=RECCOUNT()
USE IN projectlist
*--copy the project itself
FOR i = 1 TO ALEN(lcprojfiles,1)
	IF FILE((m.projnew+lcprojfiles(i,1)))
		DELETE FILE ((m.projnew+lcprojfiles(i,1))
	ENDIF
	COPY FILE (m.projold+lcprojfiles(i,1)) TO (m.projnew+lcprojfiles(i,1))
ENDFOR
CLOSE ALL
?"************"
?"Total Records in project:"+ALLTRIM(STR(lntot1))
?"Total Records in projectlist:"+ALLTRIM(STR(lntot2))
?"Total records marked for deletion:"+ALLTRIM(STR(lndeleted))
set DEFAULT TO &lcdefault
WAIT WINDOW "FINISHED!" NOWAIT
RETURN
Maybe someone else will find this useful and make it better than this quick 'down and dirty' version.

Tracy
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform