Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.3 . Guide To CA-Clipper - <b>len()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 LEN()
 Return the length of a character string or the number of elements in an array
------------------------------------------------------------------------------
 Syntax

     LEN(<cString> | <aTarget>) --> nCount

 Arguments

     <cString> is the character string to count.

     <aTarget> is the array to count.

 Returns

     LEN() returns the length of a character string or the number of elements
     in an array as an integer numeric value.  If the character string is a
     null string ("") or the array is empty, LEN() returns zero.

 Description

     LEN() is a character and array function that returns the length of a
     character string or the number of elements in an array.  With a
     character string, each byte counts as one, including an embedded null
     byte (CHR(0)).  By contrast, a null string ("") counts as zero.

     For an array, LEN() returns the number of elements.  If the array is
     multidimensional, subarrays count as one element.  This means that the
     LEN() of a nested or multidimensional array simply returns the length of
     the first dimension.  To determine the number of elements in other
     dimensions, use LEN() on the subarrays as shown in the example below.
     Note that nested arrays in CA-Clipper need not have uniform dimensions.

 Examples

     .  These examples demonstrate LEN() with various arguments:

        ? LEN("string of characters")         // Result: 20
        ? LEN("")                              // Result: 0
        ? LEN(CHR(0))                        // Result: 1
        //
        LOCAL aTest[10]
        ? LEN(aTest)                           // Result: 10

     .  This example creates a literal two-dimensional array, and then
        returns the number of elements in the subarray contained in the first
        element of the original array:

        LOCAL aArray := { {1, 2}, {1, 2}, {1, 2} }
        ? LEN(aArray)                        // Result: 3
        ? LEN(aArray[1])                     // Result: 2

     .  This example navigates a multidimensional array using LEN():

     LOCAL aArray := { {1, 2}, {1, 2}, {1, 2} }
        LOCAL nRow, nColumn, nRowCount, nColumnCount

        //
        nRowCount = LEN(aArray)
        FOR nRow = 1 TO nRowCount
           nColumnCount = LEN(aArray[nRow])
           FOR nColumn = 1 TO nColumnCount
              ? nRow, nColumn, aArray[nRow][nColumn]
           NEXT
        NEXT

     .  In this example a function returns an array of numeric values
        that describe the dimensions of a nested or multidimensional array.
        The function assumes that the array has uniform dimensions:

        FUNCTION Dimensions( aArray )
           LOCAL aDims := {}
           DO WHILE ( VALTYPE(aArray) == "A" )
              AADD( aDims, LEN(aArray) )
              aArray := aArray[1]
           ENDDO
           RETURN (aDims)

 Files   Library is CLIPPER.LIB.


See Also: AADD() ASIZE() LTRIM() RTRIM()

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