xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Array()

Creates an uninitialized array of specified length.

Syntax

Array( <nDim1> [, <nDimN,...>] ) --> aArray

Arguments

<nDim>
A comma separated list of numeric values can be passed. Each value indicates the number of elements to create for each dimension of the array. Passing a single numeric value creates a one-dimensional array.

Return

The function returns an array dimensioned according to the passed parameters. All elements of the array contain the value NIL.

Description

Array variables are usually initialized within a variable declaration. The Array() function allows for creating arrays programmatically outside a variable declaration. Array() can be part of an expression or can be called from within a code block.

The return value of Array() is a reference to an array of the specified dimensions. The number of elements in the array is limited by memory resources of the operating system.

Info

See also:AAdd(), AClone(), ACopy(), ADel(), AEval(), AFill(), AIns(), Hash()
Category: Array functions
Source:vm\arrayshb.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates different approaches of creating
// uninitialized arrays.

   PROCEDURE Main()
     LOCAL xValue
     LOCAL aArray[2,3]                  // declaration

     xValue := Array( 3, 5 )            // programmatically

     ? Len( aArray ), Len( aArray[1] )  // result: 2 3

     ? Len( xValue ), Len( xValue[1] )  // result: 3 5
   RETURN NIL

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