On Jun 15, 2012, at 3:21 PM, Bob Sneidar wrote: > Hi all. > > I am wondering if anyone has developed an Array Filter procedure that would > give me all the rows of an array matching a certain criteria? For instance, > let's say I wanted all the rows whose key "name" contained "bob" and have it > returned as an array of the same structure containing only those records? > > If not I am going to have to write one. > > Bob
Hi, Bob. Here's an example for a simple array. Put it into a script and run "test1" from the message box. Does it work for you? -- Dick <postscript> function subarrayForNameContainsString @rArray, pString local tArray repeat for each key tKey in rArray if rArray[ tKey ][ "name" ] contains pString then put rArray[ tKey ] into tArray[ tKey ] end if end repeat return tArray end subarrayForNameContainsString on test1 local tArray, tSubarray put "Betty" into tArray[ 123 ][ "name" ] put "Bob" into tArray[ 234 ][ "name" ] put "carpenter" into tArray[ 234 ][ "occupation" ] put subarrayForNameContainsString( tArray, "Bob" ) into tSubarray breakpoint end test1 </postscript> _______________________________________________ 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