CArray:Empty CArray:Get

CArray:Exists


The Exists method returns true if a CArray member exists with the specified indices.

Syntax

bSuccess = CArray:Exists( index )

Remarks

If you use Init then the first n members are set and this function will return true if tested with an index in range. Otherwise, members are not initialized if you do not Set them or if you Remove them.

Example

The following script fragment tests whether the array member at index [2] has been initialized:

 

A = CArray:new()

-- create a CArray

A:Set( 1, 0.112 )

-- set member [1]

A:Set( 2, 5.5 )

-- set member [2]

if ( A:Exists(6) ) then

-- has member [6] been set?

  s = "yes" else s = "no" end

 

Printf("A[6] exists= %s", s )

-- result: A[6] exists= no

Related Topics

CArray, Count