tcountn
The tcountn function returns the count of numeric values in a general lua table that may contain non-numeric values, named keys, and sub-tables. Only numeric values found in the table are used in the total. If the table is an array, then the total should equal the total number of indices in the array. For a general table containing string and other values, the count will be less than the number of elements in the table.
nCount = tcountn( tbl )
tbl is a general lua table.
nCount is the count of the numeric values in the table.
The following script returns the number of numeric values in an ugly, complex table. Note that the string "24" is not counted as a numeric value.
|
|
|
-- get the count |
|
-- result: Count = 6 |
Table and Array Functions, ismultidim
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.