Filter an array by content

J. Landman Gay jacque at
Fri Jun 21 03:01:19 EDT 2019

I spoke too soon. When I tested, I hard-coded a value as the filter 
string. But when I use a variable, it fails as it did before. The 
elements of the array all start with a 4-character string followed by an 
underscore, for example:  ER01_some text here

My variable contains "ER01":

   put tVar & "_*" into tFilter
   filter elements of sArray with tFilter into tNewArray

No go. I've tried a few different iterations. However, this works:

   filter elements of sArray with "ER01_*" into tNewArray

Even with no matches though, Tom was right. Looping through the keys 
takes 0.03 milliseconds. Filtering takes 0.22 ms.

On 6/21/19 1:38 AM, J. Landman Gay via use-livecode wrote:
> Thanks to all for the replies. Monte, I didn't see your post until Tom 
> quoted it, for some reason it didn't arrive here.
> At any rate, I'd already tried "filter elements of..." and it failed 
> which is why I posted. But I must have had my filter wrong because I 
> just tried it again and it worked. So that part's solved.
> And I found something interesting: when I filter a numeric array, the 
> keys remain attached and since they are numeric, they're in order. Fancy 
> that. :)
> All is well. Thanks guys.
> On 6/20/19 11:10 PM, Tom Glod via use-livecode wrote:
>> A great question Jacque ....Helpful thread all around.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list