FieldName Function (DWord, Usual) | |
Return the name of a field as a string.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION FieldName(
dwFieldPos AS DWORD,
uArea AS USUAL
) AS STRING
public static string FieldName(
uint dwFieldPos,
Usual uArea
)
Request Example
View SourceParameters
- dwFieldPos
- Type: DWord
The position of the field in the database file structure. - uArea
- Type: Usual
Specifies the work area name or number for a table from which the value must be retrieved.
Return Value
Type:
String
The name of the specified field as a string.
If
dwFieldPos does not correspond to an existing field in the database file or if no database file is open, FieldName() returns a NULL_STRING.
Remarks
FieldName() returns a field name using an index to the position of the field name in the database structure.
Use it in data-independent applications where the field name is unknown.
If information for more than one field is required, use DBStruct().
If you need additional database file structure information, use Type() and Len().
For example, to obtain the number of decimal places for a numeric field, use the following expression:
1Len(Substr(Str(<paramref name="idField" />), RAt(".", Str(<paramref name="idField" />)) + 1))
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying
it within an aliased expression or by calling the overload that accepts a workarea
parameter (a workarea number or alias ).
Examples
These examples illustrate FieldName() used with several other functions:
1USE sales
2QOut(FIELDNAME(1))
3QOut(FCount())
4QOut(LEN(FIELDNAME(0)))
5QOut(LEN(FIELDNAME(40)))
This example uses FieldName() to list the name and type of each field in CUSTOMER.DBF:
1USE customer NEW
2FOR nField := 1 UPTO FCount()
3 ? FIELDNAME(nField), DBFieldInfo(DBS_TYPE, nField)
4NEXT
This example accesses fields in unselected work areas using aliased expressions:
1USE sales NEW
2USE customer NEW
3USE invoices NEW
4QOut(Sales->FIELDNAME(1))
5QOut(Customer->FIELDNAME(1))
See Also