Click or drag to resize

FieldPos Function (String)

X#
Return the position of a field.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION FieldPos(
	cFieldName AS STRING
) AS DWORD
Request Example View Source

Parameters

cFieldName
Type: String
The name of the field.

Return Value

Type: DWord
The position of the specified field within the list of fields associated with the work area.
If the work area has no field with the specified name, FieldPos() returns 0.
Remarks
FieldPos() is the inverse of the FieldName() function. FieldPos() is most often used with the FieldPut() and FieldGet() functions.
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
This example demonstrates a typical specification of the FieldPos() function:
X#
1USE customer NEW
2QOut(FIELDPOS("Name"))                    // Result: 1
3QOut(FieldGet(FIELDPOS("Name")))            // Result: Kate
This example uses FieldPos() to return the position of a specified field in a unselected work area:
X#
1USE customer NEW
2USE invoices NEW
3QOut(Customer->FIELDPOS("Name"))            // Result: 1
4QOut(Customer->FieldGet(FIELDPOS("Name")))    // Result: Kate
See Also