> On 25 Mar 2024, at 3:00 am,Mike Kerner wrote:
> 
> i don't know if you dove into the code, but it's too early to think about
> unpacking this, so  here's the code: ...

Thanks Mike

While I was aware of the optional parameters feature of LC commands I have 
never used it I so was unfamiliar with the syntax. The penny had never dropped 
that the parameter list for a command is just an array, so evidently you can 
actually send an array instead of a comma delimited list

Which means that you can send FindIndex a single parameter pKeyPairsA which is 
an array with alternating colName,searchStr values

Setting up such an array is not particularly convenient for coding however. My 
workaround had been to use a custom function hack

function myFindIndex pDataGrid, pKeyPairs
   — pKeyPairs is a comma delimited list such as 
“colname1,str1,colname2,str2,..”

    replace comma with quote & comma & quote in pKeyPairs
    put “dispatch FindIndex to” && pDataGrid && “with” && quote & pKeyPairs & 
quote into tCommandStr
    do tCommandstr
   put the result into tFoundIndex
   ...

A much more elegant (if probably no faster) solution is

function myFindIndex pDataGrid, pKeyPairs
   — pKeyPairs is a comma delimited list such as 
“colname1,str1,colname2,str2,..”

    set the columnDelimiter to comma
    split pKeyPairs by column
    dispatch “FindIndex" to pDataGrid with pKeyPairs
   put the result into tFoundIndex
   ...


BTW, where did you find the source code for DataGrid handlers? I now see how 
one could write a FindIndices function to return all indices rather than just 
the first found … or even a general WHERE  search :-)

Neville Smythe




_______________________________________________
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

Reply via email to