xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

ASize()

Changes the number of elements in an array.

Syntax

ASize( <aArray>, <nCount> ) --> aArray

Arguments

<aArray>
This is the array whose size is changed.
<nCount>
A numeric expression specifying the number of elements the result array should have.

Return

The function returns the reference to <aArray>.

Description

The array function ASize() is used to dynamically increase or decrease the size of <aArray> to <nCount> elements. When the array is enlarged, new elements are added to the end of <aArray> and are initialized with NIL. When the number of elements is decreased, they are removed from the end of <aArray>. The values in the removed elements are lost.

The size of arrays is limited by the memory resources of the operating system.

Info

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

Example

// This example demonstrates the use of the ASize function.
// It increases and decreases the size of an array.

   PROCEDURE Main()
      LOCAL aArray := { 45 }

      ? Len( aArray )                    // result: 1

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

      ASize( aArray, 1 )
      ? Len( aArray )                    // result: 1
      ? aArray[1]                        // result: 45

   RETURN

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