How to find words and phrases as well

Eric Chatonet eric.chatonet at sosmartsoftware.com
Sun Jan 29 07:40:58 EST 2006


Hello,

I wrote my last mail from memory...
You noticed that obviously it could not work :-(
So, I dug in the "mark" solution for fun (a little bit longer but  
fast ;-)

function FindCards,pList
   local tList1,tList2,tFirstList,tSecondList
   -----
   unmark all cds
   mark cds by finding whole item 1 of pList
   if the number of marked cds = 0 then return empty
   -----
   repeat with i = 1 to the number of marked cds
     put the long name of marked cd i & cr after tList1
   end repeat
   -----
   if the number of items of pList > 1 then
     repeat with i = 2 to the number of items of pList
       unmark all cds
       mark cds by finding whole (item i of pList)
       if the number of marked cds = 0 then return empty
       repeat with j = 1 to the number of marked cds
         do "put the long name of marked cd j & cr after tList" & i
       end repeat
     end repeat
     -----
     put CommonLines(tList1,tList2) into tFirstList
     repeat with i = 3 to the number of items of pList
       do "put tList" & i && "into tSecondList"
       put CommonLines(tFirstList,tSecondList) into tFirstList
       if tFirstList = empty then return empty
     end repeat
     return tFirstList
     -----
   else return tList1
end FindCards
--------------------------
function CommonLines pFirstlist,pSecondlist
   local tFirstArray,tSecondArray
   -----
   repeat for each line thisLine in pFirstlist
     put true into tFirstArray[thisLine]
   end repeat
   repeat for each line thisLine in pSecondlist
     put true into tSecondArray[thisLine]
   end repeat
   intersect tFirstArray with tSecondArray
   return the keys of tFirstArray
end CommonLines


Le 29 janv. 06 à 12:30, Eric Chatonet a écrit :

> Hi Andre,
>
> First you could use a comma as the delimiter in your list: this  
> would allow to have words and "phrases" at the same time.
> Then just an idea I use often:
>
>   unmark all cds
>   mark cds by finding whole item 1 of fld "Keywords"
>   repeat with i = 2 to the number of items of fld "Keywords"
>     mark cds by finding whole (item i of fld "Keywords") AND the  
> mark of this cd
>   end repeat
>
> Elegant and very fast ;-)
> The process marks cards where all "items" are found at least one time.
> The trick: you can specify more than one condition to mark cards...
>
> Then you can easily get the list of current marked cards or just  
> navigate through the marked cards only:
> go next/prev marked cd
>
> Hope this helps.

Best Regards from Paris,
Eric Chatonet
------------------------------------------------------------------------ 
----------------------
http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/





More information about the use-livecode mailing list