Click or drag to resize

LocFile Function

X#
-- todo --
Locates a file on disk and returns the file name with its path.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION LocFile(
	cFileName,
	cFileExtensions,
	cFileNameCaption
) AS STRING CLIPPER
Request Example View Source

Parameters

cFileName (Optional)
Type: Usual
Specifies the name of the file to locate. If cFileName includes only a file name, LocFile( ) searches the X# default directory or folder first. If the file is not found in the default directory or folder, the X# path is then searched. Use Set PATH to specify the X# path.
If cFileName includes a path and a file name, the specified location is searched. If the file cannot be found in the specified location, LocFile( ) searches the X# default directory or folder and then the X# path.
If the file is located, LocFile( ) returns the file name and path.
cFileExtensions (Optional)
Type: Usual
Specifies file extensions for the file to locate. If the file name you specify with cFileName does not include an extension, X# applies the file extensions listed in cFileExtensions to the file name and searches for the file again.
cFileExtensions also specifies the file name extensions of the files displayed in the Open dialog box when the file you specified cannot be located.
cFileExtensions can take a variety of forms:
  • If cFileExtensions contains a single extension (for example, PRG), only files with that extension are displayed.
  • cFileExtensions can also contain wildcards (* and ?). All files with extensions that meet the wildcard criteria are displayed. For example, if cFileExtensions is ?X?, all files with the extension .fxp, .exe, or .txt are displayed.
  • In X# for Windows, cFileExtensions can contain a file description followed by a file extension or a list of file extensions separated with commas. The file description appears in the Files of Type list box. Separate the file description from the file extension or list of file extensions with a colon (:). Separate multiple file descriptions and their file extensions with a semicolon (;).
For example, if cFileExtensions is "Text:TXT" the file description "Text" appears in the Files of Type list box and all files with a .txt extension are displayed.
If cFileExtensions is "Tables:DBF; Files:TXT,BAK" the file descriptions "Tables" and "Files" appear in the Files of Type list box. When "Tables" is chosen from the Files of Type list box, all files with a .dbf extension are displayed. When "Files" is chosen from the Files of Type list box, all files with .txt and .bak extensions are displayed.
cFileNameCaption (Optional)
Type: Usual
Specifies the text you want to use to prompt the user. The text appears to the left of the textbox in which you enter the file name. If omitted, "File name:" is displayed.
For a list of X# file extensions and corresponding creator types, see the File Extensions and File Types online topic.

Return Value

Type: String
Character
Remarks
The Open dialog box is displayed if the file cannot be located in the default directory or folder, the X# path, or a specified location. The Open dialog box can be used to locate the file. When a file is chosen from the Open dialog box, the file name is returned with the file's path.
If you exit the Open dialog box by choosing Cancel, pressing Esc, or choosing Close from the Control menu, X# generates an error message and LocFile( ) does not return a value.
See Also