CheckIn, CheckOut, GetLatestVersion, UndoCheckOut

These methods allow you to move files in the Files collection into or out of your source code control provider.

Usage

lResult = filFile.CheckIn()
lResult = filFile.CheckOut()
lResult = filFile.GetLatestVersion()
lResult = filFile.UndoCheckOut()
All of these methods perform the exact same function as their like-named equivalents on the Project's context menu. Provided you have set up a source code control provider, and added this project to source code control, each of these methods tries its best to perform its function and returns .T. if successful or .F. if it fails. If source control is not set up or established for this project, the methods all return .F.CheckOut registers a file with the source code control system as yours to modify, retrieves the most recent version, and flags the local file read-write, if necessary. CheckIn reverses the process, copying your changes to the central repository and freeing the file for others to modify while locking your local copy as read-only. GetLatestVersion retrieves the latest file, but doesn't lock it for your changes—use this to make sure you're working on the latest source code before a build or a test run. UndoCheckOut lets you just give up on all of those changes you've tried that didn't work, free the program for others to work on, and retrieve a local, read-only copy of the last version checked in.

In our configuration, using Visual SourceSafe, each of these methods brings up confirmation dialogs, despite the fact that the Tools-Options-Projects check box that says "Display dialog box for shortcut menu commands" is unchecked. This ruins the entire point of manipulating these things programmatically, in our opinion. We hope Microsoft will look at this and consider a more developer-friendly interface.


Example

* Here's a routine to check out, modify a file and check in
oProject = _VFP.ActiveProject
oFile = oProject.Files[1]
IF oFile.ReadOnly  && the file must be checked in
  oFile.CheckOut()
  oFile.Modify()  && make your changes
  oFile.CheckIn()
ENDIF
 
* Scan a project and get the latest version of all the files
FOR EACH oFile in oProject.Files
  oFile.GetLatestVersion()
NEXT

See Also

Project, File, ReadOnly


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .