File move app part 2

Sarah Reichelt sarahr at genesearch.com.au
Sun Dec 7 16:39:06 CST 2003


> I have created an app to move selective files based on their filetype 
> and (sometimes) included text.
> This code (below) lets you choose a directory, walk it and view a 
> list. OK so far. Now on my second weekend learning revolution; I have 
> linked a checkbox to a filter. :-) In my edited section I filter 
> gHierList depending on whether one button is pressed. However, If I 
> want to filter for two (eg jpg and gif) I double filter and end up 
> with no selection.
>
> I thought of creating a global eg gBobList and on each line create a 
> local variable eg bobgif. Then would copy ghierlist into the local 
> variable, filter the local and add to the final global (boblist). I 
> need a global since another button will do something with this. In 
> addition I want to view the list in the window.
>

>   if the hilite of button "JPEG" is true then filter gHierlist with 
> "*.jpg"
>   if the hilite of button "BIORAD" is true then filter gHierlist with 
> "*raw*.pic"
>   if the hilite of button "GIF" is true then filter gHierlist with 
> "*.gif"
>

Hi Bob,
The problem is that once you have done the first filter, none of the 
lines will contain any of the subsequent filter texts, so as you 
discovered, you end up with nothing.
You are on the right track for a solution, but you don't need to create 
another global.
Try replacing your three lines above with this:

put empty into newList
put gHierList into tempList
if the hilite of button "JPEG" then
	filter tempList with "*.jpg"
	put tempList & cr after newList
end if
put gHierList into tempList
if the hilite of button "BIORAD" then
	filter tempList with "*raw*.pic"
	put tempList & cr after newList
end if
put gHierList into tempList
if the hilite of button "GIF" then
	filter tempList with "*.gif"
	put tempList & cr after newList
end if
put newList into gHierList

If you are ever worried about ending up with blank lines in your lists, 
here is a really neat command to delete all blank lines:
	filter myList with "*?"
I think it was Geoff Canyon who showed me that one and I find it 
invaluable :-)

Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/



More information about the use-livecode mailing list