Multiple arguments with the filter command

Marielle Lange mlange at widged.com
Wed Oct 25 14:00:19 CDT 2006


> One catch is that if the user inputs something like "53", the  
> operation
> must recognize the fact that the "53" in the first two examples is  
> not a
> part of the file name, thereby filtering them out, but that "53" is a
> part of the file name in the third example, thereby filtering it in.
> This is one reason for the exclamation point tokens in vContainer.

Now for that catch:

   put "53" into tSearch
   repeat for each item tItem in tSearch
     replace tItem with "%" & tItem in tFileList
   end repeat
   filter tFileList with "*%*"
   repeat for each line tLine in tFileList
       get matchtext(tLine & cr, "((/[^/%]*)%?([^/%]*/[^/%]*)%?([^/%] 
*))" & cr, tFull, match1, match2, match3)
       if it is true then
         replace tFull with match1 & match2 & match3 in tFileList
       end if
     end repeat
     filter tFileList with "*%*"
     replace "%" with "" in tFileList
    --> do something with  tFileList

Explanation:

well the difficult part is this one:
((/[^/%]*)%?([^/%]*/[^/%]*)%?([^/%]*)

I am afraid, that's a regular expression. They are handy but they can  
be quite daunting.
Because of the cr that follows the end of the string, this will only  
match the /<filesize>/<creationdate> parts of the string.
tFull will match the biggest parenthesis, then match1/2/3 the small  
ones.
[^/%] mean any character but / or %.
[^/%]* mean any number of character that match that pattern
%? means try to match a % if you can find one.

by replacing tFull with the set of matches I simply replace the  
string that includes the % with a string where any % doesn't appear.

Note that this may not work property if you have 53 appearing more  
than one time in the string.
What you need to do then is transform this:
[^/%]*)%?([^/%]*
into
([^/%]*)%?([^/%]*)+  which means one or more repetitions of that  
pattern.

Hope this helps,
Marielle

------------------------------------------------
Marielle Lange (PhD),  http://widged.com
Bite-size Applications for Education








More information about the use-livecode mailing list