Click or drag to resize

AFields Function

Fill arrays with the structure of the current database file. Note:  AFields() is a compatibility function and therefore not recommended.  It is superseded by DBStruct(), which does not require the existence of any arrays prior to invocation and returns a multidimensional array containing the current database file structure.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION AFields(
	 acFieldNames AS USUAL,
	 acTypes AS USUAL,
	 anWidths AS USUAL,
	 anDecimals AS USUAL
) AS DWORD
View Source

Parameters

acFieldNames
Type: Usual
The array to fill with field names.
acTypes
Type: Usual
The array to fill with the type of fields in <acFieldNames>.
anWidths
Type: Usual
The array to fill with the widths of fields in <acFieldNames>.
anDecimals
Type: Usual
The array to fill with the number of decimals defined for fields in <acFieldNames>.  If the field type is not numeric, the system assigns 0 to <anDecimals>.

Return Value

Type: UInt32
The number of fields or the length of the shortest array argument, whichever is less.  If no arguments are specified, or if there is no file in use in the current work area, AFields() returns 0.
Remarks
AFields() fills a series of arrays (structure attribute arrays) with the structure of the database file currently open, one element in each array per field.  AFields() works like ADir(), filling a series of existing arrays with information. To use AFields(), you must first create the arrays to hold the database structure information, each with the same number of elements as the number of fields (that is, FCount()).  Once the structure attribute arrays exist, you can then invoke AFields() to fill them with information about each field. By default, AFields() operates on the currently selected work area.  It can operate on an unselected work area if you specify it within an aliased expression (see example below).
Examples
This example uses AFields() with an aliased expression to fill arrays with the structure of SALES.DBF, open in an unselected work area:
X#
PROCEDURE Start()
        LOCAL acFieldNames, aTypes, aWidths, ;
                        aDecimals AS ARRAY
        USE sales NEW
        USE customer NEW
        acFieldNames := Sales->(ArrayNew(FCount()))
        acTypes      := Sales->(ArrayNew(FCount()))
        anWidths     := Sales->(ArrayNew(FCount()))
        anDecimals   := Sales->(ArrayNew(FCount()))
        Sales->(AFields(acFieldNames, acTypes, anWidths, anDecimals))
See Also