Returns the number of a specified element in a one- or two-dimensional array.

Syntax

<oRef>.element(<subscript1 expN> [, <subscript2 expN>])

<oRef>

A reference to a one- or two-dimensional array.

<subscript1 expN>

The first subscript of the element. In a one-dimensional array, this is the same as the element number. In a two-dimensional array, this is the row.

<subscript2 expN>

When <oRef> is a two-dimensional array, <subscript2 expN> specifies the second subscript, or column, of the element.

If <oRef> is a two-dimensional array and you do not specify a value for <subscript2 expN>, dBASE Plus assumes the value 1, the first column in the row. dBASE Plus generates an error if you use <subscript2 expN> with a one-dimensional array.

Property of

Array

Description

Use element( ) when you know the subscripts of an element in a two-dimensional array and need the element number for use with another method, such as fill( ) or scan( ).

In one-dimensional arrays, the number of an element is the same as its subscript, so there is no need to use element( ). For example, if aOne is a one-dimensional array, aOne.element(3) returns 3, aOne.element(5) returns 5, and so on.

element( ) is the inverse of subscript( ), which returns an element's row or column subscript number when you specify the element number.