FCount(), FldCount(), Field(), FSize()
FCOUNT() and FLDCOUNT() return the number of fields in a table. FIELD() returns the name of a specified field in a table. FSIZE() is confused: It is two different functions, depending on the setting of—ugh!—SET COMPATIBLE. Generally speaking, we avoid these commands altogether, and let AFIELDS() give us all the information at once.
Usage |
nFieldCount = FCOUNT( [ cAlias | nWorkarea ] ) nFieldCount = FLDCOUNT( [ cAlias | nWorkarea ] ) cFieldName = FIELD( nField, [ cAlias | nWorkarea ] ) * With SET COMPATIBLE OFF: nFieldSize = FSIZE( cFieldName, [ cAlias | nWorkarea ] ) * With SET COMPATIBLE ON: nFileSize = FSIZE( cFileName ) |
Parameter |
Value |
Meaning |
cAlias |
Character |
The alias of the table about which information is returned. |
Omitted |
If nWorkarea is also omitted, use current work area. |
|
nWorkarea |
Numeric |
The number of the work area containing the table about which information is returned. |
Omitted |
If cAlias is also omitted, use current work area. |
|
nFieldCount |
Numeric |
Number of fields in the specified table. |
nField |
Numeric |
Number of the field to return, based on physical order of the table. |
cFieldName |
Character |
The field's name. |
nFieldSize |
Numeric |
Size of the field (SET COMPATIBLE OFF). |
cFileName |
Character |
The name of the file. |
nFileSize |
Numeric |
Size of the file (SET COMPATIBLE ON). |
FCOUNT() and FLDCOUNT() do not report on hidden, system fields (see "DBF, FPT, CDX, DBC—Hike!"). If you use one of them with FSIZE() to try to calculate the size of a table, you'll come out with the wrong number if any of the fields are nullable. You need to use RECSIZE() or AFIELDS() to test for this, and while you're at it, you can use the return value of AFIELDS() for a better FCOUNT() and the sum of the AFIELDS() size values for a better FSIZE(). |
Example |
SET COMPATIBLE FOXPLUS USE HOME() + "LABELS" nFieldSize = FSIZE("Name", "Labels") && returns 24 SET COMPATIBLE DB4 nFileSize = FSIZE(HOME()+"Labels") && returns 6622 ? FCOUNT("LABELS") && seven ? FIELD(3, "LABELS") && returns "NAME" |
See Also |