Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hacking the ClassBrowser
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00739964
Message ID:
00740042
Views:
22
Hi Glenn,

Here is code I use the programmaticly call the CB to export classlibs and forms to a _template.prg:
LPARAMETERS tcStartDir, tlNoSubDirs,tlNoForms,tlNoClasslibs

* gen_classtemplates.prg
*
* Generates templates of classlibs and/or forms for a given directory
* The scope is with or without subdirs
*
* tcStartDir: Full Path of the directory, doesn't have to end with an backslash
* tlNoSubDirs: When set to .T. it will not include files from subdirectories
* tlNoForms: When set to .T. no templates are generated for forms
* tlNoClasslibs: When set to .T. no templates are generated for classlibs.
*
* When the name of an classlib is classlib.vcx the generates template is classlib_vcx_template.vcx
*
* It respects the settings of SET SAFETY and will act accordingly
*
* Usage:
* DO gen_classtemplates WITH "C:\VFP6LIB" && This will generate templates for forms and classlibs in C:\VFP6LIB and all subdirs
* 

IF VARTYPE(tcStartDir)<>"C"
	RETURN .F.
ENDIF

IF VARTYPE(_BROWSER)<>"O"
	DO (_BROWSER) WITH ,,,,,,.T.
*	DO c:\browser7\BROWSER.prg WITH ,,,,,,.T.
ELSE
	_BROWSER.HIDE()
ENDIF

LOCAL lnDir,lnNumDir,lnNumADir,laADIR,laDir,lnFor,lcExportFile

lnDir = 1
lnNumDir = 1
DIMENSION laDir(1)
laDir(1) = tcStartDir

DO WHILE lnDir <= lnNumDir
	DIMENSION laADIR(1,5)
	lnNumADIR = ADIR(laADIR,ADDBS(laDir(lnDir))+"*.*",'D')
	IF lnNumADIR = 0
		lnNumADIR = ADIR(laADIR,laDir(lnDir))
		laDir(lnDir)=JUSTPATH(laDir(lnDir))
	ENDIF
	IF lnNumADIR > 0
		FOR lnFor = 1 TO lnNumADIR
			IF LEFT(laADIR(lnFor,1),1) <> '.'
				IF "D"$laADIR(lnFor,5) AND NOT tlNoSubDirs 
					lnNumDir = lnNumDir+1
					DIMENSION laDir(lnNumDir)
					laDir(lnNumDir) = laDir(lnDir)+'\'+;
						ALLTRIM(laADIR(lnFor,1))
				ELSE
					IF (UPPER(ALLTRIM(RIGHT(laADIR(lnFor,1),4)))$".VCX" AND !tlNoClasslibs) OR ;
						(UPPER(ALLTRIM(RIGHT(laADIR(lnFor,1),4)))$".SCX" AND !tlNoForms)
						lcExportFile=laDir(lnDir)+'\'+STRTRAN(ALLTRIM(laADIR(lnFor,1)),".","_")
						lcExportFile=lcExportFile+"_TEMPLATE.PRG"
						IF SET('SAFETY')<>'ON' OR !FILEX(lcExportFile) OR ;
							MESSAGEBOX('File '+lcExportFile+' does exist, overwrite it?',292)=6
							_obrowser.openfile(;
								laDir(lnDir)+'\'+ALLTRIM(laADIR(lnFor,1)))
							wait window 'Creating '+lcExportFile NOWAIT
							_obrowser.exportclass(.F.,lcExportFile)
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDFOR
	ENDIF
	lnDir = lnDir+1
ENDDO
_obrowser.RELEASE()
wait window 'Creating complete' nowait
One observation:
Because the CB does not sort all properties and methods I made some changes in the Class Builder itself, along with some other changes like support for the German Version of VFP and loosely coupled Classlibs. Because it is code from the Foxteam, I don't know if I can upload my Browser.App to the files section, for copyright reasons.

Have fun,
Frank Camp
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform