How do I manually generate text files for entire project to diff in Visual FoxPro (e.g. .sca, .vca, etc.)
Asked Answered
L

2

6

The challenge is that I'm checking my FoxPro code into source control (using Mercurial, but that's not the focus of this question) and would like a quick way to get the FoxPro SCCTEXT output alongside the binary output without using the Tools > Options > Projects > Active source control provider functionality.

For an example of the kind of output I'm looking to generate, the VFPX source contains many of these text .sca, .vca, etc. files. Is there any way to generate these files on demand?

Laubin answered 25/5, 2011 at 13:20 Comment(0)
Z
4

Here is the code I use to genereate SCCText files for every file in my Project file. Just open your Project (to make sure it is the Active Project, then run this prg file).

(Updated 2011-06-10: Added a new feature that will only build new SCC text files if the DateTime of the original source file is newer than the existing SCC file. Essentially, this new version only generates a new SCC file if the VFP source file has been changed since the last time this was run.)

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

lnCount = DoSCCTextOnProject()

? Chr(10)+Chr(13)
? 'Done. ' + Str(lnCount) + ' files processed.'

*----------------------------------------------------------------------
Procedure DoSCCTextOnProject

Local loFile, loProject, lnCount

lcSCCText = Home(1) + 'SCCText.prg'
lnCount = 0
If !File(lcSCCText)
    Messagebox('Unable to find file ' + lcSCCText, 16, 'Error')
    Return 0
Endif

Try
    loProject = _vfp.ActiveProject
Catch To loEx
Endtry

If Type('loEx') = 'O'
    Messagebox('There are no active projects', 64, 'Error')
    Return 0
Endif

lcSkipFiles = 'LIST-FILES-TO-SKIP-HERE'

For Each loFile In loProject.Files

    If Inlist(loFile.Type, 'V', 'K', 'R') and ;
         !InList(Upper(JustFname(loFile.name)), Upper(lcSkipFiles)) ;
         and Fdate(loFile.name, 1) > SCCFileDateTime(loFile.name)
                ? 'Generating: ' + loFile.Name
                Do (lcSCCText) With loFile.Name
                lnCount = lnCount + 1 
    Endif
Endfor 

Return lnCount

*------------------------------------------------------------------
Procedure SCCFileDateTime(tcFile)

    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
Zebadiah answered 5/6, 2011 at 19:21 Comment(2)
FYI - If you really want to get fancy, you can create a Project Hook class, and in the the AfterBuild() event, add a line that calls this procedure and it will automatically generate your SCC files every time you build the project. You could also pop up a MessageBox() to ask if I want them built, and handle accordingly.Zebadiah
I've continued working on this a little more, and have decided to turn this into a class to do all the work, rather than the procdural way shown in the reply. You can find the code here: codepaste.net/9yy1gmZebadiah
B
7

Rather than setting a source control provider, you can hack scctext.prg (which ships with VFP) and use a project hook to generate the files - see http://paulmcnett.com/scX.php for an example implementation using Subversion.

Edit: Have you looked at the Alternate SCCText on Codeplex

Also see http://www.foxpert.com/docs/cvs.en.htm for another perspective.

Blythe answered 25/5, 2011 at 13:29 Comment(6)
This is a step in the right direction, and he lists all of the grievances I have with using VFP with source control! I'll give what he's done a look, I'm still holding out for a native way to generate an entire project's worth of .sca/.vca files or perhaps an example implementation in an answer.Laubin
Yes, I have looked at the Alternate SCCText file and I have been using it successfully to generate individual text files for comparison, but I'm still looking for a way to generate an entire project's worth of .sca/.vca/.fra files in one shot.Laubin
Can't you just walk through the project's file list and generate them?Blythe
@Stuart That's something I'd like help in concluding. The VFPX project has .sca/.vca+ files in their source control, I'm assuming that everyone who checks code into their repository is triggering something that's at least somewhat standardized and automated...Laubin
The TwoFox work you posted in your recent edit is also something I've come across, and it's again a step in the right direction, but I'm still looking for the how FoxPro generates its files meant for diffing in a normal environment (one without outside solutions like scX or TwoFox).Laubin
VFP doesn't generate files for diffing without an "outside" solution. The original SCCText.PRG shipped with VFP.Ballyhoo
Z
4

Here is the code I use to genereate SCCText files for every file in my Project file. Just open your Project (to make sure it is the Active Project, then run this prg file).

(Updated 2011-06-10: Added a new feature that will only build new SCC text files if the DateTime of the original source file is newer than the existing SCC file. Essentially, this new version only generates a new SCC file if the VFP source file has been changed since the last time this was run.)

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

lnCount = DoSCCTextOnProject()

? Chr(10)+Chr(13)
? 'Done. ' + Str(lnCount) + ' files processed.'

*----------------------------------------------------------------------
Procedure DoSCCTextOnProject

Local loFile, loProject, lnCount

lcSCCText = Home(1) + 'SCCText.prg'
lnCount = 0
If !File(lcSCCText)
    Messagebox('Unable to find file ' + lcSCCText, 16, 'Error')
    Return 0
Endif

Try
    loProject = _vfp.ActiveProject
Catch To loEx
Endtry

If Type('loEx') = 'O'
    Messagebox('There are no active projects', 64, 'Error')
    Return 0
Endif

lcSkipFiles = 'LIST-FILES-TO-SKIP-HERE'

For Each loFile In loProject.Files

    If Inlist(loFile.Type, 'V', 'K', 'R') and ;
         !InList(Upper(JustFname(loFile.name)), Upper(lcSkipFiles)) ;
         and Fdate(loFile.name, 1) > SCCFileDateTime(loFile.name)
                ? 'Generating: ' + loFile.Name
                Do (lcSCCText) With loFile.Name
                lnCount = lnCount + 1 
    Endif
Endfor 

Return lnCount

*------------------------------------------------------------------
Procedure SCCFileDateTime(tcFile)

    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
Zebadiah answered 5/6, 2011 at 19:21 Comment(2)
FYI - If you really want to get fancy, you can create a Project Hook class, and in the the AfterBuild() event, add a line that calls this procedure and it will automatically generate your SCC files every time you build the project. You could also pop up a MessageBox() to ask if I want them built, and handle accordingly.Zebadiah
I've continued working on this a little more, and have decided to turn this into a class to do all the work, rather than the procdural way shown in the reply. You can find the code here: codepaste.net/9yy1gmZebadiah

© 2022 - 2024 — McMap. All rights reserved.