FieldSym Function (DWord, Usual) | |
Return the name of a field as a symbol.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION FieldSym(
dwFieldPos AS DWORD,
uArea AS USUAL
) AS SYMBOL
public static Symbol FieldSym(
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:
Symbol
The name of the specified field as a symbol.
If
dwFieldPos does not correspond to an existing field in a database file or if no database file is open, FieldSym() returns NULL_SYMBOL.
Remarks
FieldSym() returns a field name as a symbol, 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 FieldSym() used with several other functions:
1USE sales
2QOut(FieldSym(1))
3QOut(FCount())
4QOut(LEN(FieldSym(0)))
5QOut(LEN(FieldSym(40)))
This example uses FieldSym() to list the name and type of each field in CUSTOMER.DBF:
1USE customer NEW
2FOR nField := 1 UPTO FCount()
3 QOut(PadR(FieldSym(nField), 10),;
4 VALTYPE(&(FieldSym(nField))))
5NEXT
This example accesses fields in unselected work areas using aliased expressions:
1USE sales NEW
2USE customer NEW
3USE invoices NEW
4QOut(Sales->FieldSym(1))
5QOut(Customer->FieldSym(1))
See Also