> On 15 Sep 2016, at 7:06 AM, Paul Dupuis <p...@researchware.com> wrote:
> 
> For those using LC 8.1, and have tried the new filter command's support
> for arrays, I have a question:
> 
> I see you can filter by keys or elements from the documentations, which
> is great, but I don's see how I would do another common item
> 
> Let say I have an array that is a table (a common model) where the rows
> are numeric keys and the columns keys are "field" names. So
> 
> tArray[1]["col1"] some value
> tArray[1]["col2"] some other value
> tArray[2]["col1"] still another value
> tArray[2]["col2"] and yet one more value
> 
> Can I use the new filter command to filter on a specific column and get
> all the rows matching? For example match where ["col2"] contains "some"
> which would only return row 1.
> 
> I realize I can write code to do this (and have). I was wondering if I
> am missing something obvious and there is a way to do this using the new
> filter command enhancements in 1 line.


You aren’t missing anything. Actually what you are describing is probably 
better implemented with the by clause I have suggested here:
http://quality.livecode.com/show_bug.cgi?id=18309 
<http://quality.livecode.com/show_bug.cgi?id=18309>

You could then:

filter elements of tArray by each[“col2”] is “some”

Or alternatively if you need match “something” and “somewhere”

filter elements of tArray with “some*” by each[“col2”]

Or if you need to do something interesting:

filter elements of tArray by someFunction(each)

function someFunction pArray
    return pArray[“col2”] is “some"
end someFunction

Cheers

Monte
_______________________________________________
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