Functions and Directives

Function AFields() Foundation

Fills a set of arrays with information about the fields in a work area.

AFields( [<aFieldName>], ;
         [<aFieldType>], ;
         [<aFieldLen>] , ;
         [<aFieldDec>]   ) --> nFieldCount
<aFieldName> is an array into which the names of the fields in the work area are placed. Each element of <aFieldName> contains a character string.
<aFieldType> is an array into which the field types of the fields in <aFieldName> are placed. The elements of <aFieldType>contain character strings.
<aFieldLen> is an array into which the field lengths of the fields in <aFieldName> are placed. The elements of <aFieldLen>contain integer numeric values.
<aFieldDec> is an array into which the decimal places of the fields in <aFieldName> are placed. The elements of <aFieldDec>contain integer numeric values.

The return value of AFields() is a positive integer corresponding to the number of fields for which structure information was written into the arrays. It is the value of the function FCount() or the length of the shortest array passed (the lesser of these two values). If no file is open in the work area or no arguments are passed, AFields() returns zero.


The function AFields() exists only for compatibility reasons. Instead of AFields(), the function DbStruct() should be used. DBStruct() returns the file structure in a two dimensional array.

The array function AFields() places information about the file structure of an opened DBF file into a set of arrays. When the function is used without the alias operator, it fills the arrays with the structure information for the file in the current work area. Arrays with the length FCount() should be passed to the function.

// The example generates four arrays, fills them with 
// data on the structure of a DBF file, and then displays 
// the information. 

   LOCAL aField, aType, aLen, aDec 

   USE Customer NEW 

   aField := Array( FCount() ) 
   aType  := Array( FCount() ) 
   aLen   := Array( FCount() ) 
   aDec   := Array( FCount() ) 

   AFields( aField, aType, aLen, aDec ) 

   AEval( aField, {|cField, i| ; 
                   QOut( cField, aType[i], aLen[i],aDec[i]) } ) 
   CLOSE Customer 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.