Count
The Count function returns the count of elements in a variable list that can include values, tables, and data collection objects.
nCount = Count( ... )
where
-- is a variable list of numbers, tables, CImage, CArray, and CMatrix objects.
nCount is the count (number) of elements in the list.
Since Lua implicitly converts string representations of numbers to numbers, the argument list and tables also may contain strings that can be converted to numbers.
The following script returns the count of elements in a collection of tables and numbers. This example is fairly complex to demonstrate that the method works. Note that table t is used twice in the argument list just for testing purposes.
|
-- create atable |
|
-- create another table |
|
-- createsome subtables |
|
-- create a table with strings as numbers |
|
-- assemble tables into another table |
|
-- call Count() with an argument list |
|
-- Result: Count = 27 |