Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

hollywoodlibs:tables:testcount [2016/10/16 12:03] (versione attuale)
admin creata
Linea 1: Linea 1:
 +====== TB.TEST_Count() ======
 +
 +In Hollywood there is a native function that returns how many items are stored into a table, it is **ListItem()**,​ however this function works only with tables indexed by numeric (and consecutive) values, starting from 0.
 +
 +The **TB.Count()** function is able to count every table, even the ones with strings as index.
 +
 +<​code>​
 +  Local items = { [0] = 43, 
 +                  [1] = 49, 
 +                  [4] = 192, 
 +                  music = "​test.mp3"​ }  ​
 +
 +  NPrint("​TB.COUNT ​ : ", TB.Count(items))
 +  NPrint("​ListItems : ", ListItems(items))
 +  ​
 +  NPrint("​\nENTER TO QUIT")
 +  InKeyStr(#​ALL)
 +</​code>​
 +
 +As you can see items are counted correctly using **TB.Count()**,​ even with mixed index types, while **ListItems()** stops at the first NIL index starting from 0.
 +
  
hollywoodlibs/tables/testcount.txt ยท Ultima modifica: 2016/10/16 12:03 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0