FoxPro JustDrive function

The VFP JustDrive() function returns the drive letter from a string containing the full path of a file or a directory.

For example:

JustDrive ("C:\Microsoft Visual FoxPro 9\vfp9.exe")

would return the drive letter and colon:


Note that JustDrive() does not check whether the drive actually exists, it just processes the string passed in as a parameter. The JustDrive() function will return the first two characters from the string if the second of these is a colon. If the second character is not a colon then the function will return an empty string. As an example of the problems that this can cause, the use of a valid UNC network path such as:

JustDrive ("\\XP_Server\Shipped")

would return the empty string:


We have found that the JustDrive() function is of limited use. The only time that we have found it useful is when an older application has had to run on a variety of machines, each of which had the server mapped to a different drive letter.

VBA equivalent

Microsoft Access does not have equivalents to these FoxPro file name commands so I wrote this library Visual Basic functions to do give me the same facilities in VBA.