Microsoft Corporation
October 1996
Microsoft® Visual FoxPro™ 3.0 has the capabilities for creating large enterprise-wide database applications. Its object orientation and client-server capabilities allow it to be used on projects that encompass multiple developers. In such situations, being able to place the source code under version control becomes a necessity. This article discusses using the version control features of Microsoft Visual SourceSafe™ in Visual FoxPro 3.0 application development efforts. The information in this article should be sufficient to get you started with version control using Visual SourceSafe.
Microsoft Visual SourceSafe™ provides both the control capabilities that keep one developer from overriding another's work and the versioning capabilities that allow anyone to recreate an earlier version of the software, as needed. When multiple developers will be working on one project, there should be a mechanism that ensures that only one developer will be working on any given piece of source code, ensuring that one developer does not overwrite another developer's work. Additionally, it often becomes necessary to go back to a previous version of a piece of source code in order to recreate an old build, create a new branch of the application, or to review a design decision.
Figure 1 shows Visual SourceSafe working with a Microsoft Windows® 95 Explorer type of interface.
Figure 1. Visual FoxPro application source as shown in Visual SourceSafe
As you can see, the left side of the window shows a project hierarchy, represented by folders, while the right side shows the files in the currently selected folder. Four files in the above window are currently checked out (shown by the checkmark on the file icon) and are editable by the person who checked them out (Alang), while the two highlighted text files are not checked out and cannot be edited.
It is important to note that the Visual SourceSafe Explorer uses the folder representation to show projects, not directories. This representation will serve you well if you consider this when designing your application. A well-designed project will map in a way that supports the project and the software. A project will be mapped well if it is designed as laid out in the Microsoft Visual FoxPro® Project Manager. If the SourceSafe project closely maps to the Visual FoxPro Project Manager, the consistency will decrease the learning curve.
As files are checked in and out by developers, Visual SourceSafe records what modifications are made, and allows the developer to describe each change, giving us a history of the system. Visual SourceSafe also allows developers to tag a set of files with a version number, allowing the recreation of a particular version of a system. These tags are called labels. When you label a project, the labels are inherited by the files contained in the project.
With this basic understanding of Visual SourceSafe in mind, we'll look at the issues involved in using Visual SourceSafe with Visual FoxPro.
When you install Visual SourceSafe 5.0, it includes support for Visual FoxPro files in the "File Types" section of the Options dialog of the Tools menu pad. In this section, Visual SourceSafe defines what files are to be automatically included in the add file dialog when working with a particular development platform. The default file types include all the standard Visual FoxPro file types, but is missing the .PRG file type. It will save you time if you add that in. This can be done in the SourceSafe Administrator; on the Tools menu, click Options, then click File Types, and add a semicolon, followed by an asterisk and .PRG in the file types list.
All files in a project can be checked in. The following should be noted, however:
The Visual FoxPro designers (Form, Class, Modi Comm Editor, and so forth) will allow you to view the source but not save any changes. In order to make and save changes the source files will need to be checked out. The class browser will not allow you to drag and drop a read only class onto the desktop in order to instantiate it, nor will it bring up read only classes in the class designer.
Many Visual FoxPro project components are made up of multiple files. Source code control operations should be performed on all files associated with the project component. For example, to add a form to SourceSafe, add both the .SCX and .SCT files. Then, whenever you check out the .SCX file, check out the .SCT file as well. This is not automatic, you must check out these files in "pairs" manually. You may want to set up batch files to GET, CHECKIN, and CHECKOUT these files. For example, if you want to check out the form MYSCREEN, use an (installation created) batch file that may be called SCRCKO.BAT (make sure you use the -GF- and -GWA options on the SS command in this file). The command may be something like SCRCKO MYSCREEN. This would check out both the MYSCREEN.SCX and MYSCREEN.SCT files and place them into the current directory. SCRCKIN.BAT could be created to check them in. If you do not do this, it is highly likely that a developer will forget to check out one or the other, then when checked in, the pairs will not match and you will be stuck with a non-buildable component.
Table 1. Visual FoxPro Component Files
Project Component | "Main" File Type | Implicit File Type |
Form | .SCX | .SCT |
Report | .FRX | .FRT |
Label | .FRX | .FRT |
Class Library | .VCX | .VCT |
Menu | .MNX | .MNT |
Table | .DBF | .FPT, .CDX |
Database | .DBC | .DCT, .DCX |
Project | .PJX | .PJT |
Query | .QPR | n/a |
Program Code | .PRG | n/a |
Text Files | .H and others | n/a |
Other Files | Bitmaps, masks, and other files that appear under the "Other" tab under "Other Files" in the Project Manager | .n/a |
A binary file must be checked out when it is compiled (nonbinary files, like .PRG files, compile into other files, and can be read-only when compiled). Therefore, if you select the Recompile All Files build option, all of the binary source files for the project must be checked out. In general, you will not want to select Recompile All Files.
Break into separate files or subprojects what will be separated in the division of labor. Because binary source files can only be checked out by one person at a time, multiple checkouts are not possible. This is because merging is not possible with binary files.
We acknowledge the help of Flash Creative Management, Inc., Hackensack, New Jersey, and Tom Fleming in providing portions of this material.