Search Values of Array in "One Go"

Sannyasin Brahmanathaswami brahma at hindu.org
Wed Aug 23 20:04:01 EDT 2017


Alex, thanks, this is very helpful

1) put x into aFilteredPlayListIndex[z]
(there's no need to replicate all the data when the array will continue to exist, just keep the indices you want).

awesome… I think I could increment the  z from 1  up and then my clickline number will still work.

2) "create an in-memory SQLite Database."

 this is news! Where do we find docs on this? right now the SQLite data base is in

 specialFolderPath("documents")/jnanam.sqlite

how do you "create in memory?


 

On 8/23/17, 9:06 AM, "Alex Tweedly via use-livecode" <use-livecode at lists.runrev.com> wrote:

    I'm not going to disagree with the other replies ....
    
    Plan A.   use your database
    
    Plan B.   create an in-memory SQLite database.
    
    Plan C. use an array, kind of like you are doing.
    
    And *only* if there are good reasons for not doing Plans A or B, then :
    
    C1.  Instead of
    
    repeat for each key x in aPlaylist
            repeat for each key y in aPlayList[x]
        
    
    do
    
    repeat for each key x in aPlaylist
            repeat for each element ey in aPlayList[x]
    
    Also, instead of
         put aPlayList[x] into aFilteredPlayList[z]
    
    do
         put x into aFilteredPlayListIndex[z]
    (there's no need to replicate all the data when the array will continue to exist, just keep the indices you want).
    
    
    C2. Did you really mean "check *all* columns in the array" ?
    Should it not be "check all the 'properties' columns" ?
    If so - that's another reason to use a/the database :-)
    
    C3. Create an 'allproperties' column ?
    There's probably a fast/easy way to do that either in the database, or as you extract from it - but a database expert would have to tell us how to do that.
    
    Alternatively, when you extract, just do
    
    repeat for each key x in aPlayList
       repeat for each item y in thePropertyColumns
           put aPlayList[x][y] & SPACE after aPlayList[x]["allproperties"]
       end repeat
    end repeat
    
    or, delay this until first search :
    
    repeat for each key x in aPlayList
        if aPlayList[x]["allproperties"] is empty then
           repeat for each item y in thePropertyColumns
               put aPlayList[x][y] & SPACE after aPlayList[x]["allproperties"]
           end repeat
           if aPlayList[x]["allproperties"] is empty then -- so that subsequent searches never rebuild this
             put SPACE into aPlayList[x]["allproperties"]
           end if
        end if
        if aPlayList[x]["allproperties"] contains pFilterPattern then
          put x & CR after z
        end if
    end repeat
    
      
    Alex.



More information about the use-livecode mailing list