Inspired by one of your latest replies, Leo, about using "FIND IN".. I had the idea to use that with the find-layout I open before searching. I put together these few lines, they make use of embedded functions and all works, despite the last part, that makes the find panel use the selection done within the newly opened lister. Any ideas why that is or which part needs more tweaking?
I also tried with a "Sleep" to make things settle, after SelectEx did its work to re-select the items, but to no avail.
All that happens is the find panel popping up, unfortunately it only has the sourcefolder path added and none of the selected items.
Thanks in advance, tb.
[code]//save selection
SelectEx TOVAR=tb_FindInSelected NODESELECT
//open new window
Go {sourcepath} LAYOUT=tb_Find
[
//restore selection
SelectEx FROMVAR=tb_FindInSelected MAKEVISIBLE
//optional sleep for 2 seconds (by usercommand of type script using DOpus.Delay(..);
//Sleep 2000
//variant #1: open find, passing current selection (not working)
Find IN {allfilepath}
//variant #2: open find, using current selection (also not working)
Find IN
]
[/code]
{allfilepath} probably would not be affected by changes made by your SelectEx script when run in the same command, since it would be evaluated before the script was run (I think).
There might be a kludgey way to do it by adding a call to the internal Select command but I wouldn't go down that path.
It probably makes sense to use a small script to do what you want directly, instead. Put the selected files into a string, open the layout, then tell the folder tab that you're interested in to run Find IN + your string. Much more simple.
You mean, the SelectEx command in the embedded section, does not lead to a selection, that "Find IN" can pick up?
I checked with the Say command, indeed, {allfilepath} is empty! Mhh..
thinking thinking.. ahh!
What about saving {allfilepath} with the @set modifier and throwing that at Find IN? testing testing.. works! o)
This is the final button. With small adjustments to SelectEx to not abort buttons if there is no selection, this seems to work well.
The code opens a new layout with the sourcefolder, any items will be re-selected and the find-panel has these items added.
If no items were selected, then the find panel will open with the sourcefolder as usual. Thanks Leo! o)
[code]//save selection for usage with Find IN in newly opened lister @set glob:selecteditems={allfilepath}
//save selection (if any) for usage with SelectEx (to visually restore selection)
//using NOFAIL to prevent SelectEx from aborting the button if there is no selection
SelectEx TOVAR=tb_FindInSelected NODESELECT NOFAIL
//open new layout/window
Go {sourcepath} LAYOUT=tb_Find
[
//restore selection "visually" only, it has no effect on Find IN (uses another var)
//again using NOFAIL switch to keep the button going if no selection existed/has been saved
SelectEx FROMVAR=tb_FindInSelected MAKEVISIBLE NOFAIL
//open find with selection stored by @set modifier
//if no selection was present, the find panel will use sourcefolder as expected
Find IN {$glob:selecteditems}
Do you really think it's a short script? Maybe I miss something, but as I see it, I'd need to:
loop through selected items and save them for later
run "result = RunCommand("Go .. LAYOUT")"
dig through result to find new lister and source tab
somehow reselect the files I have saved before (with another loop)
turn the items I saved into a " " separated string to throw at "Find IN" (next loop?)
setup a new command object with sourcetab etc. and finally run "Find IN "
Unexpected behaviours and mistakes aside, I feel like this would take some time.
The global var is a bit hacky I admit, but what is not when it comes to button codes? o) I think the global variable can be deleted after Find IN ran, so it would not pollute the global scope for too long. o) If I overlooked something or overcomplicated things in my mind regarding a pure script version, please let me know!
Good morning Sir! Hereby I want to try to get a response. o)
Is the script I imagine correct or too complicated in any way, since you said "a small script" would do it? Don't get me wrong, I don't won't to argue. If there is no shorter way to do it, then this is just about "what is a small script for you and me". o)