$FUNCNAME$
  AFIELDS()
$CATEGORY$
  DataBase
$SUMMARY$
   Fill arrays with the structure of the current database file
$LANG_RU$
          .
$SYNTAX$

     AFIELDS([<aFieldNames>], [<aTypes>],
	[<aWidths>], [<aDecimals>]) --> nFields


$LANG_RU$

     AFIELDS([<  >], [<  >],
	  [<  >], [<   >])
	  -->  


$ARGUMENTS$

     <aFieldNames> is the array to fill with field names.  Each element
     is a character string.

     <aTypes> is the array to fill with the type of fields in
     <aFieldNames>.  Each element is a character string.

     <aWidths> is the array to fill with the widths of fields in
     <aFieldNames>.  Each element is numeric data type.

     <aDecimals> is the array to fill with the number of decimals defined
     for fields in <aFieldNames>.  Each element is numeric data type.  If the
     field type is not numeric, the <aDecimals> element is zero.


$LANG_RU$

     <  > - ,   .  
      -  .

     <  > - ,    
        <  >.  
      -  .

     <  > - ,    
        <  >.  
      .

     <   > - ,  
        ,    
      <  >.   -  .
         ,   
       <   > - .


$RETURNS$

     AFIELDS() returns 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
     zero.


$LANG_RU$

     AFIELDS()      
      ,   ,  .   
                
      , AFIELDS()  .


$DESCRIPTION$

     AFIELDS() is an array function that 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 (i.e. FCOUNT()).  Once the structure attribute arrays are
     created, you can then invoke AFIELDS() to fill the structure arrays 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).

     AFIELDS() is a compatibility function and therefore is 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.


$LANG_RU$

     AFIELDS() - ,     
             ; 
               .
     AFIELDS()      ADIR(),  
       .   
     AFIELDS(),      ,  
            ,  
             
         (..FCOUNT()).   ,   
     ,   AFIELDS()     
        .

       AFIELDS()    , 
       AFIELDS()      .
            (.
      ).

     AFIELDS() - ,      
     xClipper.      DBSTRUCT(),  
             
      ,       
     .


$EXAMPLES$

       This example demonstrates how AFIELDS() and ACHOICE() can be
	used together to create a fields picklist:

	USE Sales NEW
	PRIVATE aFieldNames[FCOUNT()]
	AFIELDS(aFieldNames)
	@ 1, 0 TO 10, 10 DOUBLE
	nChoice := ACHOICE(2, 1, 9, 9, aFieldNames)
	@ 12, 0 SAY IF(nChoice != 0, aFieldNames[nChoice],;
			"None selected")
	RETURN

       This example uses AFIELDS() with an aliased expression to fill
	arrays with the structure of Sales.dbf, open in an unselected work
	area:

	LOCAL aFieldNames, aTypes, aWidths, aDecimals
	USE Sales NEW
	USE Customer NEW
	//
	aFieldNames := Sales->(ARRAY(FCOUNT()))
	aTypes := Sales->(ARRAY(FCOUNT()))
	aWidths := Sales->(ARRAY(FCOUNT()))
	aDecimals := Sales->(ARRAY(FCOUNT()))
	//
	Sales->(AFIELDS(aFieldNames, aTypes, ;
		 aWidths, aDecimals))


$LANG_RU$

         ,   
       AFIELDS()  ACHOICE()      :

       USE Sales NEW
       PRIVATE aFields[FCOUNT()]
       AFIELDS(aFields)
       @ 1, 0 TO 10, 10 DOUBLE
       nChoice = ACHOICE( 2, 1, 9, 9, aFields)
       @ 12, 0 SAY IF( nChoice != 0, aFields[nChoice], " ")
       RETURN

         AFIELDS()    
              Sales.dbf,
          :

       LOCAL aFieldNames, aTypes, aWidths, aDecimals
       USE Sales NEW
       USE Customer NEW
       //
       aFieldNames := Sales->(ARRAY(FCOUNT())
       aTypes := Sales->(ARRAY(FCOUNT())
       aWidths := Sales->(ARRAY(FCOUNT())
       aDecimals := Sales->(ARRAY(FCOUNT())
       //
       Sales->(AFIELDS(aFieldNames, aTypes, aWidths, aDecimals))


$SEEALSO$
  ACHOICE(),ADIR()*,AEVAL(),ASCAN(),DBCREATE(),
$END$
