6. Working with Arrays, Table Fields, and Collections : Table Field Operations : TableField Methods : WhichRow Method
 
Share this page                  
WhichRow Method
A table field generally displays a subset of the rows in its associated array. For example, the table field may display only four rows at a time, although the underlying array contains 20 rows. Therefore, a data item currently displayed in the third row of the table field might actually belong to the thirteenth row of the array.
To determine which array row contains the value in a specific cell in a table field, use the WhichRow method. The syntax for WhichRow is:
integer = tablefield.WhichRow(cellfield = FormField)
The return value identifies the array row that contains the data displayed in the specified cell field. If the specified cell field is not part of the table field or is part of an empty row, this method returns zero.
One common use of this method is in ChildExit event processing, to determine whether the user has exited a row within a table field rather than moved to another column within the same row:
if field(custtable).currow !=
    field(custtable).whichrow(cellfield=
        curframe.targetfield)
then
    /* The row is being exited */
endif;
This expression on the left side of the if statement:
field(cust_table).currow
returns the number of the array row that last had the input focus. The expression on the right side, because the specified cell field is the target field, returns the array row number of the row that gets the input focus next. If the row numbers returned by these two expressions are not the same, then the user has moved the cursor up or down a row.