ID: Q97156
The information in this article applies to:
The "Commands & Functions" manual for FoxPro 2.0 for MS-DOS and the "FoxPro Language Reference" manual for FoxPro 2.5 for MS-DOS and Windows do not list an example of using the AFIELDS() function. The following example illustrates how the AFIELDS() function can be used to help determine the number of decimal places in a field named numfld.
In the code snippet below, AFIELDS() is used to create an array containing field information. The array contains four columns: field name, field type, field length, and decimal places in numeric fields. One row in the array is created for each field in the database structure. The field names and field types are placed in the array as uppercase character strings.
The ASCAN() function scans the fldinfo array to find the field named numfld and returns the element number for the field name. The number of decimal places for the field is three elements past the field name.
1. Create a database with the following two fields. Data records do
not need to be added for this example.
Field Type Length Decimals
-----------------------------------------------------------
CHARFIELD C 10
NUMFLD N 10 3
2. USE the database just created.
3. Issue the following commands in the Command window:
?AFIELDS(fldinfo) && Creates an array named fldinfo.
m.decimals = fldinfo(ASCAN(fldinfo,"NUMFLD") + 3)
?m.decimals
NOTE: M.decimals should contain a value of 3, which is the number of
decimal places in the field named NUMFLD.
Pages C3-126 and C3-144 of the FoxPro 2.0 for MS-DOS, "Commands &
Functions".
Pages L3-182 and L3-206-207 of the FoxPro 2.5 for MS-DOS and
Windows "Language Reference".
Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbprg
KBSubcategory: FxprgGeneral
Last Reviewed: June 27, 1995