Field Function | |
Returns the name of a field, referenced by number, in a table.
Namespace:
XSharp.VFP
Assembly:
XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax FUNCTION Field(
uField,
uArea,
nFlag
) AS STRING CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static string Field(
Usual uField = default,
Usual uArea = default,
Usual nFlag = default
)
Request Example
View SourceParameters
- uField (Optional)
- Type: Usual
Specifies the name of a field. This is used primarily to retrieve the actual field caption as stored
in a database container (DBC) when used with the nFlag parameter.
If the field caption is an expression (=), the expression is evaluated. Otherwise, the actual string literal is returned.
If the expression cannot be evaluated at run time, an error is raised, and the actual field name is returned.
Or
Specifies the field number. If nFieldNumber is 1, the name of the first field in the table is returned;
if nFieldNumber is 2, the name of the second field is returned, and so on. The empty string is returned if nFieldNumber is greater than the number of fields.
Field names are returned in upper case.
- uArea (Optional)
- Type: Usual
Specifies the work area of the table for which Field( ) returns field names.
Field( ) returns the empty string if a table is not open in the work area you specify.
Or
Specifies the alias of the table for which Field( ) returns field names.
X# generates an error message if you specify a table alias that does not exist.
- nFlag (Optional)
- Type: Usual
Specifies whether the actual field name or field caption is returned.
Return Value
Type:
String
Character data type. If you omit the optional arguments,
Field( ) returns the names of the fields in the table open in the currently selected work area.
Remarks
You can use the
Select( ) function to determine the current work area for nWorkArea. You can use the
Alias( ) function to determine
the alias of the table in the current work area for cTableAlias. For more information, see Select( ) Function and Alias( ) Function.
nFlags | Value description |
---|
0 |
Return actual field name. Field( ) preserves the case of the returned field name, as long as the table is stored in a DBC.
|
1 | Return field caption. If the field caption is an expression, return its evaluated value. |
Examples 1Close Databases
2Open Database (HOME(2) + 'Data\testdata')
3Use customer
4Clear
5For gnCount = 1 TO FCOUNT( )
6? Field(gnCount)
7Next
8?
9? 'Number of fields: ' + ALLTRIM(STR(gnCount -1))
See Also