AElement(), ASubscript()
These two functions convert between the two numbering schemes for array elements: continuous element numbering and row/column numbering. Because some array functions use one form and others need the other form, these functions are pretty useful. AELEMENT() takes an array, a row and, optionally, a column and returns the corresponding element number. ASUBSCRIPT() takes an array and an element number and returns either the row or the column.| Usage | nElement = AELEMENT( ArrayName, nRow [, nCol ] ) |
| Parameter | Value | Meaning |
| ArrayName | Array Name | The array in which you want to convert from row, column notation to element notation. It's necessary to specify the array because the shape of the array determines the conversion. |
| nRow | Numeric | The row number of the item for which the element number is desired. |
| nCol | Numeric | The column number of the item for which the element number is desired. |
| Omitted | Treat ArrayName as a one-dimensional array and return nRow. | |
| nElement | Numeric | The element number of the specified element. If the array is one-dimensional or nCol is omitted, nRow is returned. |
| Example | DIMENSION aTest[5], a2DTest[4,2] ? AELEMENT(aTest, 3) && returns 3 ? AELEMENT(a2DTest, 3) && returns 3 ? AELEMENT(a2DTest, 3, 2) && returns 6 |
| Usage | nSubscript = ASUBSCRIPT( ArrayName, nElement, nSubscript ) |
| Parameter | Value | Meaning |
| ArrayName | Array Name | The array in which you want to convert from element notation to row, column notation. It's necessary to specify the array because the shape of the array determines the conversion. |
| nElement | Numeric | The element number of the item for which either the row or column number is desired. |
| nSubscript | 1 | Return the row subscript of the element. In a one-dimensional array, this is the same as the element number. |
| 2 | Return the column subscript of the element. In a one-dimensional array, gives an error message. |
| Example | DIMENSION aTest[5],a2DTest[4,2] ? ASUBSCRIPT(aTest, 3, 1) && returns 3 ? ASUBSCRIPT(a2DTest, 3, 1) && returns 2 ? ASUBSCRIPT(a2DTest, 3, 2) && returns 1 * The next example assumes SearchItem has a value * that can be found in the array. ? ASUBSCRIPT(a2DTest, ASCAN(a2DTest, SearchItem), 1) |
| See Also | ALen(), Array Manipulation, AScan() |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.