Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> arraylen() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    ARRAYLEN()

Purpose:     Count the number of contiguous elements in an array.

Syntax:      ARRAYLEN( array )

Arguments:   array       - Array in which to count the contiguous
                           elements.

Returns:     The number of contiguous elements in an array, starting at
             the beginning array element.

Description: ARRAYLEN() is useful for determining the actual number of
             elements in an array where some elements may be missing.  The
             LEN() function returns the length of an array as it was
             declared.  However, if all of the array positions are not
             filled, and you try to parse each element in a FOR loop, you
             will encounter a run time error on the undeclared elements.

Notes:       Will return zero if an invalid array parameter or no
             parameter is passed and will set RLIBERROR().

Example:     DECLARE array[10]
             array[1] = "Hello"
             array[2] = " world."

             FOR x = 1 TO LEN(array)       && will be 10
                ?? array[x]                && on #3 will produce run-time
             NEXT x                        &&  error Undefined Identifier

             *-- corrected version
             FOR x = 1 TO ArrayLen(array)  && will be 2
                ?? array[x]
             NEXT x

Source:      RL_ARRAY.PRG

See also:    ALIST()

See Also: ALIST()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson