CMatrix:Count


The Count method returns the number of rows defined in the CMatrix object.

Syntax

number = CMatrix:Count()

bullet.gif    On success, this method returns the number of rows defined in the matrix.

bullet.gif    On failure, this method returns 0.

Remarks

This method returns the number of rows defined in the CMatrix. This is not the same thing as the maximum index in the row direction. For example, if the CMatrix has 2 rows, one at index (1,1) and the other at index (5,10000), then there are 2 rows defined and Count = 2.

Example

Suppose a CMatrix assigned to M contains 2 rows 3 members as shown below. This script returns the count and the number of members:

M = new_matrix()

-- create a CMatrix

M:Set( 2, 44, 1805 )

-- set member 2, 44

M:Set( 120, 20, 102 )

-- set member 120, 20

M:Set( 120, 2, 600.5 )

-- set member 120, 2

Printf("rows = %d", M:Count())

-- result: rows = 2

Printf("mem = %d", M:Members())

-- result: mem = 3

M:delete()

-- if finished with M, clean up memory

Related Topics

CMatrix class, Exists, Members


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