xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FieldPut()

Assigns a value to a field variable by its ordinal position.

Syntax

FieldPut( <nFieldPos>, <xValue> ) --> xAssigneValue

Arguments

<nFieldPos>
A numeric value specifying the ordinal position of the field variable to assign a value to. <nFieldPos> must be in the range from 1 to FCount().
<xValue>
An expression whose value is assigned to the field variable. The data type of <xValue> must match the data type of the field variable. Note that memo fields must be assigned character strings.

Return

The function returns the value assigned to the specified field variable, or NIL if <nFieldPos> is outside the valid range.

Description

FieldPut() assigns a value to a field variable by using its ordinal position, rather than its field name. The ordinal position is determined by the sequence of field declarations when a database file is created. Ordinal positions begin with 1 and end with FCount().

Info

See also:DbFieldInfo(), FieldDec(), FieldGet(), FieldLen(), FieldName(), FieldPos(), FieldType(), REPLACE
Category: Database functions , Field functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates various possibilities of
// assigning a value to a field variable.

   PROCEDURE Main
      LOCAL cField := "LASTNAME" , cLastName := "Miller"

      USE Customer NEW ALIAS Cust

      Cust->LASTNAME := cLastName      // hard-coded assignment

      ? FieldPos( cField )             // result: 3

      ? FieldPut( 3, cLastName )       // result: Miller

                                       // aliased expression
      Cust-> ( FieldPut( FieldPos(cField), cLastName ) )

      USE
   RETURN

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