Function Array() Foundation

Creates an array with the specified dimensions.

Syntax
Array( <nDimension1> [, <nDimensionX>...] ) --> aArray
Parameters
<nDimension1>
<nDimension1> indicates the number of elements in the first dimension (the length of the array).
<nDimensionX>
For each additional argument <nDimensionX>, a subarray is created with <nDimensionX> elements.
Return

The return value of Array() is an array which has the specified number of elements per dimension. All array elements contain the value NIL.

Description

The array function Array() creates an array which contains the value NIL in all elements (except for Array(0) which creates an empty array which has no elements). If the argument <nDimensionX> is included, an array with <nDimensionX> elements is assigned to each array element of the dimension <nDimension1>. These arrays also have the value NIL in all elements.

In Xbase++ neither the number of dimensions nor the number of elements per array is limited.

Examples
Three possible ways to create an array
// The example shows three ways in which an array 
// can be created in Xbase++. 

PROCEDURE Main 
** Create array in LOCAL assignment ************** 
   LOCAL aArray1Dim[5]                 // one dimensional 
   LOCAL aArray2Dim[5,2]               // two dimensional 
   LOCAL aArray3Dim[2,3,2]             // three dimensional 


** Create array with function Array()  ************ 
   aArray1Dim := Array(5)              // one dimensional 
   aArray2Dim := Array(5,2)            // two dimensional 
   aArray3Dim := Array(2,3,2)          // three dimensional 

** Create literal array  ****************************** 
                                       ** one dimensional 
   aArray1Dim := {NIL,NIL,NIL,NIL,NIL} // first dimension 

                                       ** two dimensional 
   aArray2Dim := { ;                   // open first dimension 
                   {NIL,NIL}, ;        // second dimension 
                   {NIL,NIL}, ; 
                   {NIL,NIL}, ; 
                   {NIL,NIL}, ; 
                   {NIL,NIL}  ; 
                 }                     // close first dimension 

                                       ** three dimensional 
   aArray3Dim := { ;                   // open first dimension 
                   { ;                 // open second dimension [1] 
                     {NIL,NIL}, ;      // third dimension 
                     {NIL,NIL}, ; 
                     {NIL,NIL}  ; 
                   },;                 // close second dimension 
                   { ;                 // open second dimension [2] 
                     {NIL,NIL}, ;      // third dimension 
                     {NIL,NIL}, ; 
                     {NIL,NIL}  ; 
                   } ;                 // close second dimension 
                 }                     // close first dimension 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.