[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 [ ]
 Array element indicator                         (Special)
------------------------------------------------------------------------------
 Syntax

     <aArray>[<nSubscript>, ... ]
     <aArray>[<nSubscript1>][<nSubscript2>] ...

 Operands

     <aArray> is an expression that returns a reference to an array.
     This is generally a variable identifier or instance variable.

     <nSubscript> is a numeric expression that addresses an individual
     element in the specified array or subarray.  Each subscript corresponds
     to a dimension of the array.

 Description

     The subscript operator ([]) specifies a single array element.  The name
     of a previously declared array must precede the left bracket and the
     array element subscript must appear as a numeric expression within the
     brackets.  You can make array element references using Pascal or C-style
     syntax.

 Examples

     .  This example accesses each element in a two-dimensional array
        of known dimensions:

        LOCAL i, j
        FOR i := 1 TO 5
           FOR j := 1 TO 10
              ? aOne[i, j]
           NEXT
        NEXT

     .  These examples specify an <aArray> expression:

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

        FUNCTION ArrayFunc
           STATIC aArray := { 1, 2 }
           RETURN aArray

     .  This example queries and assigns a static array encapsulated
        within a function definition:

        ? ArrayFunc()[1]                     // Result: 1
        ArrayFunc()[1] := 10
        ? ArrayFunc()[1]                     // Result: 10

        FUNCTION ArrayFunc
           STATIC aArray := { 1, 2 }
           RETURN aArray


See Also: ARRAY() LOCAL PRIVATE PUBLIC STATIC
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson