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' nowaitOne observation: