xHarbour Reference Documentation > Function Reference |
Retrieves the ordinal position of a field variable by its name.
FieldPos( <cFieldName> ) --> nFieldPos
The function returns a numeric value indicating the ordinal position of the field variable <cFieldName> in the work area. If the work area has no field variable with this name, the return value is zero.
FieldPos() accepts a field name as character string and retrieves from it the ordinal position of the field variable. This is the reverse functionality of function FieldName(). Both FieldPos() and FieldName() are used for programming generic database routines that work with unknown database structures.
See also: | DbFieldInfo(), FCount(), FieldDec(), FieldGet(), FieldLen(), FieldName(), FieldPut(), FieldType() |
Category: | Database functions , Field functions |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates a typical use for FieldPos(). PROCEDURE Main LOCAL cName USE Customer NEW ? cLast := FieldGet(FieldPos("LASTNAME")) // result: Miller ? FieldPos("LASTNAME") // result: 3 USE RETURN
http://www.xHarbour.com