Fills referenced arrays with database field information


      AFields(<aNames>[,<aTypes>][,<aLen>][,<aDecs>]) --> <nFields>


<aNames> Array of field names

<aTypes> Array of field names

<aLens> Array of field names

<aDecs> Array of field names


<nFields> Number od fields in a database or work area


This function will fill a series of arrays with field names, field types, field lenghts, and number of field decimal positions for the currently selected or designed database. Each array parallels the different descriptors of a file’s structure. The first array will consist of the names of the fields in the current work area. All other arrays are optional and will be filled with the corrensponding data. This function will return zero if no parameters are specified or if no database is avaliable in the current work area. Otherwise, the number of fields or the lenght of the shortest array argument, witchever is smaller, will be returned.

AFIELDS() is a compatibility function, it is superseded by DBSTRUCT() which returns one multidimensional array.

NOTE: The destination arrays must be initialized to a given size, usually FCOUNT(), before calling this function.


      PROCEDURE Main()
         LOCAL aNames, aTypes, aLens, aDecs, nCount, nFields, i
         USE Test

         nCount := FCount()
         ? "Number of fields:", nCount
         PrintFields( nCount )   // Information for all fields
         PrintFields( 4      )   // Information for first 4 fields

      PROCEDURE PrintFields( nCount )
         LOCAL aNames, aTypes, aLens, aDecs, nFields, i

         aNames  := Array( nCount )
         aTypes  := Array( nCount )
         aLens   := Array( nCount )
         aDecs   := Array( nCount )
         nFields := aFields( aNames, aTypes, aLens, aDecs )

         ? "Number of items :", nFields
         FOR i := 1 TO nFields
            ?  i, PadR( aNames[ i ], 12 ), aTypes[ i ]
            ?? aLens[ i ], aDecs[ i ]




Library is rdd



3 responses to “AFields()

  1. Pingback: Harbour All Functions — A | Viva Clipper !

  2. Pingback: Harbour Database Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.