Click or drag to resize

Functions.AFields Method

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.18
Request Example View Source


acFieldNames (Optional)
Type: Usual
The array to fill with field names.
acTypes (Optional)
Type: Usual
The array to fill with the type of fields in acFieldNames.
anWidths (Optional)
Type: Usual
The array to fill with the widths of fields in acFieldNames.
anDecimals (Optional)
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: DWord
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.
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, 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
This example uses AFields() with an aliased expression to fill arrays with the structure of SALES.DBF, open in an unselected work area:
 2    LOCAL acFieldNames, aTypes, aWidths, ;
 3            aDecimals AS ARRAY
 4    USE sales NEW
 5    USE customer NEW
 6    acFieldNames := Sales->(ArrayNew(FCount()))
 7    acTypes      := Sales->(ArrayNew(FCount()))
 8    anWidths     := Sales->(ArrayNew(FCount()))
 9    anDecimals   := Sales->(ArrayNew(FCount()))
10    Sales->(AFields(acFieldNames, acTypes, anWidths, anDecimals))
See Also