xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FieldPos()

Retrieves the ordinal position of a field variable by its name.

Syntax

FieldPos( <cFieldName> ) --> nFieldPos

Arguments

<cFieldName>
A character string holding the name of the field variable.

Return

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.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe