Multiple arguments with the filter command

Jim Ault JimAultWins at yahoo.com
Wed Oct 25 13:54:01 EDT 2006


On 10/25/06 9:04 AM, "Mark Powell" <mark_powell at symantec.com> wrote:

> Another text filtering question, please.  I have studied the archives
> but have not found precisely the solution that works.
> 
> I have a container vContainer of file names, each line of the form
> 
>   <directory>/!?!<filename>!/<filesize>/<creationdate>
> 
> Here are three literal examples:
> 
>   C:/The World/Asia/!?!prologue.ps!/1026/1115309596
>   C:/The World/Europe/!?!Map of Europe.jpg!/3536844/1155845730
>   C:/The World/!?!About1953.txt!/4288/1161776573
> 
> User-input text strings can define what files from vContainer are to be
> retained. The following works to filter-in the first example above:
> 
>   filter vContainer with ("*!*.ps*!*")
> 
> However, if the user wants both ".ps" and "Europe" to be retained, how
> best to do it without repeat loops and a lot of temporary copies of
> vContainer?  Is there a way?
> 
> 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.
> 

You need to decide if you are going to use:
replace "/a/" with "b:" in vContainer
wild cards
regEx
or a combination of these.

Using "?" as a delimiter will create problems for wild cards (which are the
basis of the 'filter' command) and regEx.

Perhaps the best way for you is to take a tip from html & xml and use a tag
style

< C:/The World/Asia/><prologue.ps><1026/1115309596>
<C:/The World/Europe/><Map of Europe.jpg></3536844/1155845730>
<C:/The World/><About1953.txt></4288/1161776573>

get vContainer 
filter it with "*<*><*Europe*.ps*><*>*"

get vContainer 
filter it with "*<*><*53*><*>*"
get vContainer 
filter it with "*<*53*><*><*>*"

--building variables and substitution (not tested)---------
put "" into dirTag; put "Europe*.jpg*" into fileTag
get vContainer 
filter it with "*<*"& dirTag&"><*"&fileTag&"><*>*"

put "53*" into dirTag; put "" into fileTag
get vContainer 
filter it with "*<*"& dirTag&"><*"&fileTag&"><*>*"

put "" into dirTag; put "53*" into fileTag
get vContainer 
filter it with "*<*"& dirTag&"><*"&fileTag&"><*>*"

Further, 
set the itemdel to ">"
get item 3 of line 1 of it  =>     </3536844/1155845730

Of course, in building your lists, you need to watch the occurance of "<" &
">" in the data you are searching.

Hope this gives you some ideas

Jim Ault
Las Vegas





More information about the Use-livecode mailing list