Click or drag to resize

FCount Function

Return the number of fields in the current database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION FCount() AS DWORD
View Source

Return Value

Type: UInt32
If there is no database file open, FCount() returns 0.
Remarks
FCount() is useful in applications containing data-independent programs that can operate on any database file.  These include generalized import/export and reporting programs.  Typically, you use FCount() to establish the upper limit of a FOR...NEXT or DO WHILE loop that processes a single field at a time. By default, this function operates on the currently selected work area.  It can be made to operate on an unselected work area by specifying it within an aliased expression.
Examples
This example uses FCount() to return the number of fields in the current and an unselected work area:
X#
USE Sales NEW
USE Customer NEW
? FCount()                                        // Result: 5
? Sales ->(FCount())                        // Result: 8
This example uses FCount() to declare an array with field information:
X#
LOCAL aFields := ARRAY(FCount())
AFields(aFields)
This example uses FCount() as the upper boundary of a FOR loop that processes the list of current work area fields:
X#
LOCAL nField
USE Sales NEW
FOR nField := 1 UPTO FCount()
        ? FIELDNAME(nField)
NEXT
See Also