filter question

Phil Davis davis.phil at
Tue Mar 14 18:39:56 EST 2006

Chris Sheffield wrote:
> I'm not really 100% sure to be honest.  I think it's because in my  case 
> I have to account for filtering with only a partial string.  So  for 
> example, if my user enters "a", the filter needs to return any  records 
> where say the third item of each line begins with "a".

Right. That's where my solution breaks down. It assumes that the 
"Filter" field is always complete before filtering occurs.

I wonder if it would work with the addition of "*" at both ends of the 
Filter field? I don't see why that wouldn't work - then the filter will 
only be looking for a string of contiguous chars in that item of each 
line, rather than requiring the item to start or end with the chars.

Phil Davis

> Because Phil's solution uses tabs around the filter string (tab & fld  
> "filter" & tab), it doesn't work quite right for me.  I tried a  couple 
> different modifications, including placing *'s between the  filter 
> string and the tabs, to make it work for me but couldn't find  anything 
> that worked in all cases.
> Hope that provides you with a little more information.
> Chris
> On Mar 14, 2006, at 12:25 PM, Jim Ault wrote:
>> Hey, Chris,
>> I know you probably don't have the time, but I am wondering why Phil's
>> solution did not work.  I use the filter command all the time and  
>> Phil had
>> the correct syntax and useage, as far as I could see.
>> Mostly just curiosity to find exceptions or tricky problems for future
>> reference.  Surprised it did not work.
>> Thanks,
>> Jim Ault
>> Las Vegas
>> On 3/14/06 11:01 AM, "Chris Sheffield" <cmsheffield at> wrote:
>>> Thanks, Sarah.  I ended up going with a solution similar to this to
>>> get the job done.  I thought Phil's suggestion would have worked, and
>>> that's what I was trying to do, but unfortunately it didn't.
>>> But thanks to all who responded.
>>> Chris
>>> On Mar 13, 2006, at 5:08 PM, Sarah Reichelt wrote:
>>>> It might be faster to filter the list simply to reduce it to lines
>>>> that contain the filter string anywhere, and then do a loop to check
>>>> if the filter string is in the correct item.
>>>> -- gather the original data and the required settings
>>>> put fld "List" into tList
>>>> put fld "Filter into Filter
>>>> put 3 into tItemNum
>>>> -- do the first filter to reduce the list
>>>> filter tList with "*" & tFilter & "*"
>>>> -- loop through making sure it appears in the right item
>>>> put empty into tMatches
>>>> repeat for each line L in tList
>>>>   if item tItemNum of L contains tFilter then put L & cr after
>>>> tMatches
>>>> end repeat
>>>> -- remove the trailing cr
>>>> delete last char of tMatches
>>>> -- display the matching results
>>>> put tMatches into fld "Results"
>>>> Sarah
>>>> On 3/14/06, Phil Davis <davis.phil at> wrote:
>>>>> Hi Chris,
>>>>> To filter on column 3, are you using something like this?
>>>>>    put fld "list" into tList
>>>>>    filter tList \
>>>>>        with "*" & tab & "*" & tab & fld "filter" & tab & "*"
>>>>>    put tList into fld "list"
>>>>> Phil Davis
>>>>> Chris Sheffield wrote:
>>>>>> I'm trying to apply a filter to a list field.  The columns of
>>>>>> the  field
>>>>>> are tab delimited.  I have a separate "filter" field that  allows
>>>>>> the
>>>>>> user to apply a filter to the list based on whichever  column  is the
>>>>>> current sort column.  I can get the filter to work fine  so long
>>>>>> as the
>>>>>> first column is selected, but anything else does not  work.
>>>>>> How can I apply a filter to a list based on say item 3 of each
>>>>>> line  of
>>>>>> that list?  Is that possible?
>>>>>> Thanks,
>>>>>> Chris

More information about the Use-livecode mailing list