Finding Table Items
With TB.Item.Find() it's easy to retrieve strings from a table, here is the example coming with the library:
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
This function need the following improvements
- Ability to optionally return all found items