Differenze

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

Link a questa pagina di confronto

hollywoodlibs:tables:testitemfind [2016/10/18 11:04] (versione attuale)
admin creata
Linea 1: Linea 1:
 +====== Finding Table Items ======
  
 +With **TB.Item.Find()** it's easy to retrieve strings from a table, here is the example coming with the library:
 +
 +<​code>​
 +Function TB.TEST_ItemFind()
 +  DebugPrint("​TESTING TB.Item.Find()"​)
 +  ​
 +  Local items = { "​Jhonny", ​
 +                  "​Michael", ​
 +                  "​Henry", ​
 +                  "​Mark", ​
 +                  "​Ryan", ​
 +                  "​Cody", ​
 +                  "​Fred", ​
 +                  "​Jim", ​
 +                  "​Paul", ​
 +                  "​Sam",​
 +                  "​*Joe"​ }
 +  ​
 +  DebugPrint("​\nLooking for '​mark'​ : Case Sensitive : OFF, Exact String : OFF")
 +  Local found, index = TB.Item.Find(items,​ "​mark",​ False, False)
 +  ​
 +  If found
 +    DebugPrint("​First result @ " .. index .. " -> " .. items[index])
 +  Else
 +    DebugPrint("​NOT FOUND!"​)
 +  EndIf
 +  ​
 +  DebugPrint("​\nLooking for '​*a*'​ : Case Sensitive : OFF, Exact String : OFF")
 +  Local found, index = TB.Item.Find(items,​ "​*a*",​ False, False)
 +  ​
 +  If found
 +    DebugPrint("​First result @ " .. index .. " -> " .. items[index])
 +  Else
 +    DebugPrint("​NOT FOUND!"​)
 +  EndIf
 +  ​
 +  DebugPrint("​\nLooking for '​Ma*'​ : Case Sensitive : ON, Exact String : OFF")
 +  Local found, index = TB.Item.Find(items,​ "​*a*",​ False, False)
 +  ​
 +  If found
 +    DebugPrint("​First result @ " .. index .. " -> " .. items[index])
 +  Else
 +    DebugPrint("​NOT FOUND!"​)
 +  EndIf
 +  ​
 +  DebugPrint("​\nLooking for '​Joe'​ : Case Sensitive : ON, Exact String : On")
 +  Local found, index = TB.Item.Find(items,​ "​Joe",​ False, False)
 +  ​
 +  If found
 +    DebugPrint("​First result @ " .. index .. " -> " .. items[index])
 +  Else
 +    DebugPrint("​NOT FOUND!"​)
 +  EndIf  ​
 +  ​
 +  DebugPrint("​\nLooking for '​*Joe'​ : Case Sensitive : ON, Exact String : On")
 +  Local found, index = TB.Item.Find(items,​ "​*Joe",​ False, False)
 +  ​
 +  If found
 +    DebugPrint("​First result @ " .. index .. " -> " .. items[index])
 +  Else
 +    DebugPrint("​NOT FOUND!"​)
 +  EndIf  ​
 +  ​
 +  DebugPrompt("​\n\nHit ENTER to quit?"​)
 +EndFunction
 +</​code>​
 +
 +FIXME
 +**This function need the following improvements**
 +  * Ability to optionally return all found items
hollywoodlibs/tables/testitemfind.txt ยท Ultima modifica: 2016/10/18 11:04 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0