CArray:Empty


The Empty method deletes all members of the CArray but does not delete the CArray object.

Syntax

CArray:Empty()

Remarks

This deletes all array members without deleting the CArray object itself. If you delete the CArray, the object is set to nil and cannot be used again without creating a new instance using new. By calling Empty, the existing CArray can be used to Set new members, and so forth.

Example

The following script sets 3 members in a new CArray M, then deletes all members of M:

A = new_array()

-- create a CArray

A:Set( 127, -63.25 )

-- set member

A:Set( 100, 12.34 )

-- set member

A:Set( 4, -42 )

-- set member

Printf("Members = %d", A:Count() )

-- result: Members = 3

A:Empty()

-- empty the array

Printf("Members = %d", A:Count() )

-- result: Members = 0

A:delete()

-- if finished with A, clean up memory

Related Topics

CArray


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.