Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Project Hook
Message
From
24/05/2004 11:57:04
 
 
To
24/05/2004 07:02:32
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00906447
Message ID:
00906559
Views:
24
This message has been marked as the solution to the initial question of the thread.
Even though I did not have a method of doing this, I found it an interesting challenge. Here is what I came up with.

1. First create a Class from a ProjectHook baseclass.
Create Class MyPjxHook as ProjectHook of MyPjxHook
Then Modify the QueryModifyFile, and add this code.
LPARAMETERS oFile, cClassName

IF TYPE("_OpenFiles")#"C"
    PUBLIC ARRAY _OpenFiles[1,3]
    PUBLIC _CloseFileTimer
    _CloseFileTimer = NEWOBJECT( "phTimer", THIS.CLASSLIBRARY )
ELSE
    PUBLIC ARRAY _OpenFiles( ALEN(_OpenFiles,1)+1,3 )
ENDIF
_OpenFiles( ALEN(_OpenFiles,1),1 ) = JUSTFNAME(oFile.NAME)+IIF(NOT EMPTY(JUSTFNAME(cClassName))," ("+JUSTFNAME(cClassName)+")", JUSTFNAME(cClassName))
_OpenFiles( ALEN(_OpenFiles,1),2 ) = TRANSFORM(FDATE( oFile.NAME ))+" "+FTIME( oFile.NAME )
_OpenFiles( ALEN(_OpenFiles,1),3 ) = FULLPATH(oFile.NAME)

RETURN
The LPARAMETER statement is already provided, and does not need to be added again.

In the Destory event, add this code.
RELEASE _OpenFiles
RELEASE _CloseFileTimer
Close this class

Create a second class based on the Timer baseclass
Create Class phTimer as Timer of MyPjxHook
In the Timer event place
private i, f
f=.f.
FOR i=1 TO ALEN(_OpenFiles,1)
	DO case
	CASE EMPTY( _OpenFiles(i,1) )
	CASE EMPTY( _OpenFiles(i,2) )
	CASE EMPTY( _OpenFiles(i,3) )
	CASE NOT WEXIST( _OpenFiles(i,1) )
		this.FileClosed( i )
	CASE NOT WEXIST( "Class Designer - "+_OpenFiles(i,1) )
		this.FileClosed( i )
	CASE NOT WEXIST( "Form Designer - "+_OpenFiles(i,1) ) 
		this.FileClosed( i )
	CASE NOT WEXIST( "Report Designer - "+_OpenFiles(i,1) )
		this.FileClosed( i )
	CASE NOT WEXIST( "Label Designer - "+_OpenFiles(i,1) )
		this.FileClosed( i )
	CASE NOT WEXIST( "Menu Designer - "+_OpenFiles(i,1) )
		this.FileClosed( i )
	ENDCASE 
NEXT

IF f
	f = ALEN(_OpenFiles,1)
	FOR i=ALEN(_OpenFiles,1) TO 1 STEP -1
		IF EMPTY(_OpenFiles(i,1))
			=ADEL(_OpenFiles,i)
			f=f-1
		ENDIF
	NEXT
	DIMENSION _OpenFiles(MAX(1,f),3)
ENDIF 

RETURN
Create a new method from the File menu / New Property called FileClosed. Edit the new method and add this code.
LPARAMETERS i

LOCAL cFile, lchg
cFile = _OpenFiles(i,3)
lchg = .F.
lchg = lchg or (FILE(cFile) AND TRANSFORM(FDATE( cFile ))+" "+FTIME( cFile ) > _OpenFiles(i,2))
lchg = lchg or (FILE(STUFF(cFile,LEN(cFile),1,"t")) and TRANSFORM(FDATE( STUFF(cFile,LEN(cFile),1,"t") ))+" "+FTIME( STUFF(cFile,LEN(cFile),1,"t") ) > _OpenFiles(i,2) )
IF lchg
		STRTOFILE("The file'" + _OpenFiles(i,1) + "'" + ;
			" modified at " + TRANSFORM(FDATE( cFile ))+" "+FTIME( cFile ) + ;
			" by "+TRANSFORM(SYS(0))+ ;
			CHR(13)+chr(10), "Pjx.log",.t.)
		_OpenFiles(i,1) = ""
		f=.t.
ENDIF 
RETURN
Close this class too.

In the Project Info dialog of the project to be tracked, Assign the new projecthook class to the project.

Close and reopen the project in project manager.

Now when a file is modified via the Project Manager, a line is writen in a file called Pjx.Log.

I threw this together and have not tested under all file types.

Hopes this helps some.
Greg
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform