Click or drag to resize

FFCount Function

X#
Return the number of files that match a given file specification and attribute.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION FFCount(
	pszFileSpec AS STRING,
	dwAttributes AS DWORD
) AS DWORD
Request Example View Source

Parameters

pszFileSpec
Type: String
The names of the files to include, including 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.
dwAttributes
Type: DWord
One or more of the following constants indicating the file attributes to be used with pszFileSpec as search criteria:
ConstantDescription
FA_DIRECTORY Directory
FA_VOLUME Vorume
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).
dwAttributes 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 dwAttributes argument.
Tip Tip
To specify volume labels only, to the exclusion of all other files, specify FA_VOLUME as the sole dwAttributes argument.
"

Return Value

Type: DWord
The number of files matching the specified criteria.
If no match is found, it returns zero.
Remarks
FFCount() also finds the first file matching the specified criteria.
Therefore, it is not necessary to call FFirst() immediately after FFCount(). Instead, retrieve the necessary information about the first matching file using other related functions (such as FName(), FSize(), FAttrib(), FTime(), or FDate()), then call FNext() to move on to the next file.
This technique is illustrated in the example below.
Examples
This example uses FFCount() in conjunction with FNext() and FName() to display all files matching "C:\DOCS\*.TXT":
X#
1dwMatches := FFCount("c:\docs\*.txt", FC_NORMAL)
2FOR i:= 1 UPTO dwMatches
3    ? FName()
4    FNext()
5NEXT
This example illustrates the dwAttributes argument, extending the file search to include hidden files and directories, as well as visible files:
X#
1dwCnt := FFCount("c:\i*.*", FC_HIDDEN + FA_DIRECTORY)
2FOR i:= 1 UPTO dwCnt
3    ? FName()
4    FNext()
5NEXT
See Also