CodePaste Logo
New Snippet New Recent Snippets Recent Snippets My Snippets My Snippets My Favorites Favorites Web Code Search Snippets Search
Sign inor Register
Language: foxpro

FoxPro class to generate SCCText for all files in a Project

* See blog post: * *=========================================================================== lnResponse = MessageBox('Run SSCText to generate ascii code files?', 3, 'Generate SCC files?') If lnResponse <> 6 Return EndIf *Clear All *Release All Set ClassLib to && Must clear them out, cause we're about to generate ascii files of them loCreateSccText = CreateObject('CreateSCCText') llReturn = loCreateSccText.DoSCCTextOnProject() If llReturn = .t. ? Chr(10)+Chr(13) ? 'Done. ' + Str(loCreateSccText.nFileCount) + ' files processed.' Else ? 'Result:' + loCreateSccText.cMessage Endif *================================================================ Define Class CreateSCCText as Custom cSkipFiles = 'LIST-FILES-TO-SKIP-HERE' nFileCount = 0 cSccTextApp = Home(1) + 'SCCText.prg' cMessage = '' *---------------------------------------------------------------------- Procedure DoSCCTextOnProject Local loFile, loProject If !File(This.cSccTextApp) This.cMessage = 'Unable to find file ' + lcSCCText Return .f. Endif Try loProject = _vfp.ActiveProject Catch To loEx Endtry If Type('loEx') = 'O' This.cMessage = 'There are no active projects' Return .f. Endif For Each loFile In loProject.Files If Inlist(loFile.Type, 'V', 'K', 'R') and ; !InList(Upper(JustFname(, Upper(This.cSkipFiles)) ; and Fdate(, 1) > This.SCCFileDateTime( ? 'Generating: ' + loFile.Name Do (This.cSCCTextApp) With loFile.Name This.nFileCount = This.nFileCount + 1 Endif Endfor Return .t. *------------------------------------------------------------------ Procedure SCCFileDateTime(tcFile) Local lcSCCFilename lcSCCFilename = Upper(Strtran(Upper(tcFile), '.SCX', '.SCA')) lcSCCFilename = Strtran(lcSCCFilename, '.VCX', '.VCA') lcSCCFilename = Strtran(lcSCCFilename, '.FRX', '.FRA') If File(lcSCCFilename) Return Fdate(lcSCCFilename, 1) Else Return {^1900-01-01 00:00:00} EndIf EndProc *---------------------------------------------------------------- Procedure DoSccTextOnFile Lparameters tcFile Local lcOutput, lcType If !File(tcFile) Messagebox('File not found: ' + tcFile, 0, 'Error') Return .F. Endif Do Case Case '.VCX' $ Upper(tcFile) lcOutput = Getwordnum(tcFile, 1, '.') + '.vca' lcType = 'V' Case '.SCX' $ Upper(tcFile) lcOutput = Getwordnum(tcFile, 1, '.') + '.sca' lcType = 'K' Otherwise Return Endcase Do (SCCText) With tcFile, lcType, lcOutput, .T. Endproc EndDefine
by Matt Slay
  June 10, 2011 @ 11:44am
by Rick Borup    June 10, 2011 @ 4:01pm

Nice job, Matt. One little thing: I believe line 59 should reference This.nFileCount instead of This.nCount. Also, as a possible enhancement, you might consider excluding anything outside the project folder, either by default or as an option. As it stands, this class creates scctext files for all vcx, etc. that are found in the project, including native VFP class libraries such as ffc\registry.vcx. Not a problem, just a suggestion. - Rick Borup

by Alejandro A Sosa    June 28, 2013 @ 7:16am

Well done. To get around the problem that recompiling the project changes the date of vcxs and other tables, you can compare text produced by scctext app with previosuly produced text. If it is the same, leave existing file, otherwise change it. Alex Sosa

by Matt Slay    June 20, 2011 @ 8:40pm

Hi Rick - You are correct about this.nFileCount.<br /> Also, that's a good idea to exclude stuff outside the project folder. I think there should be a property on the class to control that.

Add a comment

Report Abuse
brought to you by:
West Wind Techologies