AFIELDS( ) Function

Example   See Also

Places information about the structure of the current table into an array and returns the number of fields in the table.

Syntax

AFIELDS(ArrayName [, nWorkArea | cTableAlias])

Returns

Numeric

Arguments

ArrayName

Specifies an array into which information about the table structure is placed. If the array you include in AFIELDS( ) doesn't exist, Visual FoxPro automatically creates it. If the array exists and isn't large enough to contain all the information returned by AFIELDS( ), the size of the array is automatically increased to accommodate the information.

nWorkArea

Specifies the work area of the table for which structure information is placed into an array.

cTableAlias

Specifies the alias of the table for which structure information is placed into an array.

If you omit nWorkArea and cTableAlias, structure information is placed in an array for the table in the currently selected work area.

The following table describes the content of each column in the array and the data type of the information stored in each column. One row is created for each field in the table.

Column number Field info Data type
1 Field name Character
2 Field type:
C = Character
D = Date
L = Logical
M = Memo
N = Numeric
F = Float
I = Integer
B = Double
Y = Currency
T = DateTime
G = General
Character
3 Field width Numeric
4 Decimal places Numeric
5 Null values allowed Logical
6 Code page translation not allowed Logical
7 Field validation expression Character
8 Field validation text Character
9 Field default value Character
10 Table validation expression Character
11 Table validation text Character
12 Long table name Character
13 Insert trigger expression Character
14 Update trigger expression Character
15 Delete trigger expression Character
16 Table comment Character

Remarks

AFIELDS( ) returns the number of fields in the table. The array contains 16 columns and the same number of rows as fields in the table.

You can use COPY STRUCTURE EXTENDED to place similar information into a table instead of an array.