xHarbour Reference Documentation > Operator Reference xHarbour Developers Network  

{ }

Literal array.

Syntax

{[<expressions,...>]}

Arguments

<expressions,...>
<expressions,...> is a comma separated list of expressions that may yield any data type, including arrays. When an expression evaluates to an array, or when another literal array is specified, a nested, or multi-dimensional array is created.

Description

This operator is used as a delimiter for creating references to literal arrays. Expressions listed within the curly braces are evaluated and their return value is stored in the elements of the newly created array.

Note:  When a variable is declared as STATIC, the expressions may only be constant values that can be resolved at compile time.

Info

See also:[ ] (array), {=>}, Array(), Hash()
Category: Operators , Special operators
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates arrays of different dimensions.

   PROCEDURE Main
      LOCAL aAge := {12, 15, 11, 9, 11, 14} // one dimensional
      LOCAL aUsers := { {"John", 31}, ;     // two dimensional
                        {"Marc", 28}, ;
                        {"Bill", 33}  }

      LOCAL aVal := { Date(), ;             // three dimensional
                      { 1, 2, {.T., "Ok"} }, ;
                     "Third Element" }

      ? aAge[3]                        // result: 11
      ? aUsers[2][1]                   // result: Marc
      ? aVal[2,3,2]                    // result: Ok
      ? aVal[3]                        // result: Third Element
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe