FoxPro DefaultExt() function

The VFP DefaultExt() function returns the filename with the specified extension if it has no extension already.

For example:

DefaultExt ("C:\Microsoft Visual FoxPro 9\vfp9.exe", "bak")

would return

"C:\Microsoft Visual FoxPro 9\vfp9.exe"

because the filename already has an extension.

Note that this function will assume that a filename which ends in a period does already have an extension and will not add the new extension.

If you do need to replace any existing extension then use the ForceExt function.

Note that you must not include the period in the required extension. FoxPro does not check for the validity of the name that is generated and will return a filename with a double period.

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.

MS Access technical tips

Visual FoxPro technical tips

General Tips

 

More tips from Alvechurch Data

FoxPro Functions

FoxPro has always had functions like FREAD and FWRITE to read and write files at a low level. They can handle files which defeat the STRTOFILE and FILETOSTR functions.

Read More

FoxPro ForceExt function

FoxPro functions to manipulate names of files and folders

Read More

FoxPro ForcePath function

FoxPro functions to manipulate names of files and folders

Read More

FoxPro JustExt function

FoxPro functions to manipulate names of files and folders

Read More

FoxPro JustFName function

FoxPro functions to manipulate names of files and folders

Read More