Page 1 of 1

Save Filters As Collection

Posted: 02 May 2020 21:33
by Anklebuster
Is there a menu operation for saving different sets of filters for a tab? If not, would a single-line script for each filter be able to be saved in the Catalog?

I use a catalog to hold a simple script to toggle thumbnails (::#302) and I'm guessing I can stash filters in the same way.

I tested ::#354. That's sort of okay, as I can click the down-arrow to recall other filters. Is this the best way?

Ideally, I would have a catalog item that applies a specific filter.

Re: Save Filters As Collection

Posted: 02 May 2020 22:02
by highend
You could write a script that saves the current configuration to a temp .ini file, read the mruVisualFilter section from it and e.g. display its entries as a popup menu.
That would only be one entry in the catalog.

E.g.:

Code: Select all

$tmpIni = "%TEMP%\~XY.ini";
    savesettings 1, $tmpIni;
    $vFilters  = regexreplace(gettoken(getsectionlist("mruVisualFilter", $tmpIni), 2, <crlf>, "t", 2), "(^\d+=[""]|[""]$)");
    $selection = popupmenu($vFilters, 7:="<:::>"); // Arbitrary item separator to not break a filter containing ";"
    if ($selection) { filter $selection, 1+4; }

Re: Save Filters As Collection

Posted: 04 May 2020 19:25
by Anklebuster
Thanks highend, this looks promising.

Cheers,

Mitch

Re: Save Filters As Collection

Posted: 04 May 2020 20:57
by Anklebuster
What am I doing wrong?
::load "C:\Users\MA\AppData\Roaming\XYplorer\Scripts\filterview";


I was reading through Stefan's scripting manual and tried creating this Catalog entry as
::load "filterview";


Cheers,

Mitch

Re: Save Filters As Collection

Posted: 04 May 2020 21:16
by highend
Show a picture of the properties of that entry

Re: Save Filters As Collection

Posted: 05 May 2020 07:00
by Anklebuster
For the time being, I'm just using ::#354; which simulates Ctl+J.

Is that what your script does, as well?

Here is the catalog property which attempts to call your script. I should note that I added a name to the script. Was that necessary? Did I do it properly?

Code: Select all

"filterview"
    $tmpIni = "%TEMP%\~XY.ini";
    savesettings 1, $tmpIni;
    $vFilters  = regexreplace(gettoken(getsectionlist("mruVisualFilter", $tmpIni), 2, <crlf>, "t", 2), "(^\d+=[""]|[""]$)");
    $selection = popupmenu($vFilters, 7:="<:::>"); // Arbitrary item separator to not break a filter containing ";"
    if ($selection) { filter $selection, 1+4; }
Image

Re: Save Filters As Collection

Posted: 05 May 2020 07:21
by highend
Using my script requires one click less than #354;

If this doesn't matter you can also use #354; instead.

My script doesn't require a name it works as it is.

I don't know what happens when you execute the catalog entry. Does it present an error message?

You don't need the full path to a script as long as it is in <xyscripts> folder (which seems to be the case).

So you've created a file named C:\Users\MA\AppData\Roaming\XYplorer\Scripts\filterview.xys?
and copied the script I've posted 1:1 into it?

If you're not sure if the script is executed at all, remove the name at the top of it (that you've added)
and use e.g. a text "hi"; instead...

Re: Save Filters As Collection

Posted: 05 May 2020 14:10
by Anklebuster
It worked! I started from the beginning. I see how your script saves a step. That is very cool.
Thanks for your help!

Cheers,

Mitch

Image

Re: Save Filters As Collection

Posted: 05 May 2020 14:29
by highend
No problem and thanks a bunch for the donation :beer:

Re: Save Filters As Collection

Posted: 05 May 2020 17:26
by Anklebuster
My pleasure, highend!

FYI, both your script and #354 work hand in hand to speed up things. I use the Ctl-J when I need to create a new filter or to clean up the existing one. Of course, then I use your script to quickly select among them.

Cheers,

Mitch

Re: Save Filters As Collection

Posted: 05 May 2020 18:43
by highend
That sounds like the perfect way to handle this!