Click or drag to resize

ASubScript Function

X#
Returns the row or column subscript of an element from the element's number.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION ASubScript(
	ArrayName AS FOXARRAY,
	nElementNumber AS DWORD,
	 nSubscript AS DWORD
) AS DWORD
Request Example View Source

Parameters

ArrayName
Type: FoxArray
Specifies the name of the array.
nElementNumber
Type: DWord
Specifies the element number.
nSubscript
Type: DWord
Determines if the row or column subscript is returned.

Return Value

Type: DWord
Numeric
Remarks
If the array is one-dimensional, include the element number in nElementNumber and 1 in nSubscript. ASubscript( ) identically returns nElementNumber.
If the array is two-dimensional, include both the element number nElementNumber and a value of 1 or 2 in nSubscript. Specifying 1 in nSubscript returns the row subscript of the element, and specifying 2 returns the column subscript.
For more information on how to reference elements in an array, see DIMENSION.
You can refer to elements in two-dimensional variable arrays in one of two ways. The first method uses two subscripts to specify the row and column position of the element in the array. The second method uses an element number. Use ASubscript( ) to obtain an element's row or column subscript from the element's number.
In the following example, an array with two rows and three columns is created. Display MEMORY shows the contents of the elements of the array listed in element number order.
X#
1DIMENSION gaMyArray(2,3)
2Display MEMORY LIKE gaMyArray
3GAMYARRAY  Pub  A
4( 1, 1)   L  .F. (element number 1)
5( 1, 2)   L  .F. (element number 2)
6( 1, 3)   L  .F. (element number 3)
7( 2, 1)   L  .F. (element number 4)
8( 2, 2)   L  .F. (element number 5)
9( 2, 3)   L  .F. (element number 6)
Each of these commands stores the character string INVOICE to the same array element:
X#
1STORE 'INVOICE' TO gaMyArray(2, 1)
2STORE 'INVOICE' TO gaMyArray(4)
In one-dimensional arrays, an element's number is identical to its single row subscript. It isn't necessary to use ASubscript( ) with one-dimensional arrays.
See Also