Click or drag to resize

FFirst Function

Find the first file that matches a given file specification or attribute.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.6
Syntax
 FUNCTION FFirst(
	pszFileSpec AS STRING,
	kAttributes AS DWORD
) AS LOGIC
Request Example View Source

Parameters

pszFileSpec
Type: String
The file specification for the search.  Besides a file name, this specification can include an optional drive, directory, and extension.
The file name and extension can include the standard wildcard characters (* and ?).
If the drive and directory are omitted, the Windows default is used.
kAttributes
Type: UInt32
One or more of the following constants indicating the file attributes to be used with <pszFileSpec> as search criteria:
Constant Description
FA_DIRECTORY Directory
FA_VOLUME Volume
FC_HIDDEN Hidden
FC_NORMAL Visible
FC_SYSTEM System
To specify more than one constant, you can either add attributes together, as in FC_SYSTEM + FC_HIDDEN, or use the _Or() operator, as in _Or(FC_SYSTEM, FC_HIDDEN).
<kAttributes> specifies a criterion to satisfy in addition to any "visible" files that match the <pszFileSpec>.  Visible files do not include directories, volumes, or hidden or system files — all other files are visible, regardless of the status of their read or archive attributes.
To include only visible files, use FC_NORMAL as the <kAttributes> argument.
Note:To specify volume labels only, to the exclusion of all other files, specify FA_VOLUME as the sole <kAttributes> argument.

Return Value

Type: Boolean
TRUE if a match is found; otherwise, FALSE.
Remarks
FFirst() gets the first matching file; use FNext() to find subsequent matching files. FFCount() returns the number of matches.  FAttrib(), FDate(), FName(), FSize(), and FTime() return the attribute, date stamp, name, size, and time stamp of the matching file, respectively.
Examples
This example uses FFirst() to find a file:
X#
1IF FFirst("c:\docs\*.txt", FC_NORMAL)
2    ? "A file was found"
3ELSE
4    ? "A file was not found"
5ENDIF
This example illustrates the <kAttributes> argument, extending the file search to include hidden files and directories, as well as visible files:
X#
1IF FFirst("c:\i*.*", FC_HIDDEN + FA_DIRECTORY)
2    ? "A file was found"
3ELSE
4    ? "A file was not found"
5ENDIF
See Also