Click or drag to resize

FieldPut Function

X#
Set the value of a field identified by its position.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION FieldPut(
	nFieldPos AS USUAL,
	uNewValue AS USUAL
) AS USUAL
Request Example View Source

Parameters

nFieldPos
Type: Usual
The position of the field in the database file structure.
uNewValue
Type: Usual
The value to assign to the field.
The data type of this expression must match the data type of the field.

Return Value

Type: Usual
The value assigned to the field. If nFieldPos does not correspond to the position of any field in the database file, FieldPut() will generate an error. The exception to this is the XBase++ dialect where an invalid nFieldPos will not generate an exception but will return NIL.
Remarks
FieldPut() allows you to set the value of a field using its position within the database file structure rather than its field name. Within generic database service functions this allows, among other things, the setting of field values without use of the macro operator. Note: FieldPut() can be used with a BLOB field (that is, a memo field associated with a BLOB file), provided the length of the field does not exceed 64 KB. 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
Shared mode:
For a shared database, this function requires a record lock.
Examples
This example compares FieldPut() to functionally equivalent code that uses the macro operator to set the value of a field:
X#
1// Using macro operator
2FName := FIELDNAME(nFieldPos)                // Get field name
3_FIELD->&FName := FVal                    // Set field value
4// Using FieldPut()
5FieldPut(nFieldPos, FVal)                    // Set field value
See Also