ID()

ALen()

This function returns the number of elements, rows or columns in an array. For one-dimensional arrays, it returns the number of elements. For two-dimensional arrays, a parameter determines whether it returns elements, rows or columns. We often forget to include the parameter when asking for rows and end up with elements by accident. A better approach is to always pass 1 for the second parameter unless you specifically want the number of columns. With a one-d array, you still get the number of elements, but for a two-d array, you'll get rows, which is what we almost always want.

Usage

nReturnValue = ALEN( ArrayName [, nElemRowOrCol ] )

Parameter

Value

Meaning

ArrayName

Array Name

The array whose elements, rows or columns are to be counted. Can be either one- or two-dimensional.

nElemRowOrCol

0 or Omitted

Returns the number of elements in the array.

1

Returns the number of rows in a two-dimensional array. For a one-dimensional array, returns the number of elements.

2

Returns the number of columns in a two-dimensional array. Returns 0 for a one-dimensional array.

nReturnValue

Numeric

The number of elements, rows or columns in ArrayName.


Example

USE Employee COPY TO ARRAY aEmps FIELDS Last_Name, First_Name nCount = ALEN(aEmps,1)   * check if an array is two-dimensional IF ALEN(MyArray, 2) = 0    * one-dimensional ELSE    * two-dimensional ENDIF
Also, see the function aColCopy() under ACopy() for examples of ALEN() in use.

See Also

ACopy(), AElement(), Array Manipulation, ASubscript(), Dimension


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net