Create a fast search function

GeoffT660

Active Member
Licensed User
Longtime User
I'm looking to create a function that can quickly lookup any column (field), in any table with a supplied value. This would then set the position on a TableView or other similar list type view in under a second. The tables could have up to 10000 rows. Something like RowNum = SearchVal("TableName","ColumnName","Value") returning the RowNum to set the position in the TableView or a -1 if the value is not found. I have accomplished this on Palm and WM but so far have not found this functionality in B4a or on this forum. Let me know as I will pay for helping me the various hassles I have with the transition from my older programs to Android/B4a and eventually Apple. Also, let me know if this is just not possible. Thanks.
 

stevel05

Expert
Licensed User
Longtime User
The attached file adds a lookup sub to the Flexible Table class: https://www.b4x.com/android/forum/threads/class-flexible-table.30649/
(You will need to install the dependencies if you haven't already).

The search time is fast, and there is no special indexing done. See if this helps.

There is currently no errorchecking if the data isn't found, but that is easily added.
 

Attachments

  • SearchTest.zip
    28.1 KB · Views: 322

GeoffT660

Active Member
Licensed User
Longtime User
Thanks for this as it works very well. I made a small donation and would be willing to pay for the Not Found functionality and I also need incremental search (Search for Next Occurrence) and also Search Substring if these are possible and you are able and willing. Let me know and thanks again for this initial solution.
 

stevel05

Expert
Licensed User
Longtime User
Try this, there is a new class to manage the lookup (specifically lookup next), and an additional sub in the table class. Substring search is also in there.

Errors are currently reported with a toast, but you can use whatever error reporting your existing app uses.
 

Attachments

  • SearchTest2.zip
    28.8 KB · Views: 304

GeoffT660

Active Member
Licensed User
Longtime User
Thanks so much on your help with this and after a little integration all the search functionality works perfect on a table with over 22K records and is faster then my previous programs from different OS's. I added another donation and let me know how I can reach you if you are interested in more work. Thanks again.
 
Top