subscript( )
Topic group Related topics Example
Returns the row number or the column number of a specified element in an array.
Syntax
<oRef>.subscript(<element expN>, <row/column expN>)
<oRef>
A reference to the array.
<element expN>
The element number.
<row/column expN>
A number, either 1 or 2, that determines whether you want to return the row or column subscript of an array. If <row/column expN> is 1, subscript( ) returns the number of the row subscript. If <row/column expN> is 2, subscript( ) returns the number of the column subscript.
If <oRef> is a one-dimensional array, dBASE Plus returns an error if <row/column expN> is a value other than 1.
Property of
Array
Description
Use subscript( ) when you know the number of an element in a two-dimensional array and want to reference the element by using its subscripts.
If you need to determine both the row and column number of an element in a two-dimensional array, call subscript( ) twice, once with a value of 1 for <row/column expN> and once with a value of 2 for <row/column expN>. For example, if the element number is in the variable nElement, execute the following statements to get its subscripts:
nRow = aExample.subscript( nElement, 1 )
nCol = aExample.subscript( nElement, 2 )
In one-dimensional arrays, the number of an element is the same as its subscript, so there is no need to use subscript( ). For example, if aOne is a one-dimensional array, aOne.subscript(3) returns 3, aOne.subscript(5) returns 5, and so on.
subscript( ) is the inverse of element( ), which returns an element number when you specify the element subscripts.