FoxPro AddBS() function

The VFP AddBS() function adds a final backslash to a path if it does not already end in a backslash. For example:

AddBS ("C:\Microsoft Visual FoxPro 9")

would return the path with a final backslash:

"C:\Microsoft Visual FoxPro 9\"

but if the path being passed in already ends in a backslash:

AddBS ("C:\Microsoft Visual FoxPro 9\")

then the function would not add another backslash but would return:

"C:\Microsoft Visual FoxPro 9\"

Note that you can pass a path with forward slashes into AddBS() but the function will always add a backslash, even if the path already ends with a forward slash.

AddBS() will not add a backslash to an empty string.

AddBS() is particularly useful when you are processing pathnames or assembling a path from a number of separate components. If you use the GetDir() function to let the user select a folder from the directory tree then you will always get the path with a final backslash. If you are using another technique to enter paths or if you are importing the paths from another application then AddBS() lets you add a consistent backslash to these values and avoid errors when you try to assemble a pathname and file without backslashes.

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.