Is there a quick way to search a large multidimensional array that I
am missing? I'm working on an inventory system and trying to figure
out some more efficient methods.
Currently I'm taking a tab-delimited spreadsheet provided by the
client and converting it to an array, but there are currently > 48000
keys in the array so my repeat loop for searching is taking several
minutes. I quickly figured out by making the barcode (unique value)
the primary key of the array cut down on a simple SKU search, but I'm
trying to also search based on other values (like the item description).
A line of sample data looks like this:
66290 PHOTO, Early to Mid 1960's, Womens Hair Style, 27x21" Blue
Background w/ White Vine Edging, Gold Frame 1 $200.00
An item in the array looks like this:
tInventoryArray[66290]["barcode"]
tInventoryArray[66290]["description"]
tInventoryArray[66290]["details"]
tInventoryArray[66290]["qty"]
tInventoryArray[66290]["cost"]
My slow, albeit working, search code looks like this:
repeat for each element tThisItem in tInventoryArray
if tThisItem["description"] contains tSearchQuery then
put tThisItem into tSortedInventoryArray[(the number of
elements of tSortedInventoryArray) + 1]
end if
end repeat
This does work, but is taking almost 2 minutes to search through the
48000+ item database. Can someone point out a flaw in my process? My
next experiment is converting this array to a SQLlite database and
just throwing SELECT * WHERE commands at it.
--Andrew Bell
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode