Search Values of Array in "One Go"
brahma at hindu.org
Wed Aug 23 11:24:32 EDT 2017
We use these arrays with media metadata that is extracted from our database of media metadata. The dbase was originally designed for lots of columns so that "there is nothing we cannot know about a media item" incorporating DCIM columns and also W3C media metadata initiative's recommended properties. In actually usage for any give media item only a small subset of columns containe any data. but we do use almost all the columns at one time or another. There are no blobs, so this is very light weight data.
Anyway… this results in arrays which contain 1 top level key per record and that element contains another 40 or so keys for the columns of the database. most of which are empty/unused. So these arrays are never "heavy" in terms of bytes.
aPlayList may have 1000 keys (numeric 1-1000)
where each top level key contains a whole record:
in each one we have
# and 30+ more "properties" for the media item
OK so let's say user want sto search "blues" and I want the UX to check *all* columns in the array. What is the best way to do this?
I tried a simple test.
put "apple" into aFruits["1"]
put "orange" into aFruits["2"]
put "plum" into aFruits ["3"]
put aFruits contains "orange"
and it returns "false"
The only other strategy I can see would be
put 1 into z # for our new filtered play list
repeat for each key x in aPlaylist
repeat for each key y in aPlayList[x]
if aPlayList[x][y]contains "blues" then
put aPlayList[x] into aFilteredPlayList[z]
add 1 to z
So then if we started with 1000 "records" in the array and we found "blues" in any column of any record, for, say 20 of them, we end up with a new array.
aFilteredPlayList # containing top level keys 1-20 for 20 records, put the titles into a list field and viola: the clickline number matches the array key and away we go.
OK I can make this work, (have to since I don't see another way)
But it seems like a lot of looping.
Is there a more efficient approach?
More information about the Use-livecode