Save Filters As Collection

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Save Filters As Collection

Post 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.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Save Filters As Collection

Post 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; }
One of my scripts helped you out? Please donate via Paypal

Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Re: Save Filters As Collection

Post by Anklebuster »

Thanks highend, this looks promising.

Cheers,

Mitch

Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Re: Save Filters As Collection

Post 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

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Save Filters As Collection

Post by highend »

Show a picture of the properties of that entry
One of my scripts helped you out? Please donate via Paypal

Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Re: Save Filters As Collection

Post 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
Attachments
tabfilter-in-catalog.png
tabfilter-in-catalog.png (17.78 KiB) Viewed 2153 times
Last edited by highend on 05 May 2020 14:32, edited 1 time in total.
Reason: code tags instead of inline code -> Unreadable without correct line breaks

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Save Filters As Collection

Post 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...
One of my scripts helped you out? Please donate via Paypal

Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Re: Save Filters As Collection

Post 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
Attachments
tabfilter-in-catalog-working.png
tabfilter-in-catalog-working.png (371.14 KiB) Viewed 2132 times

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Save Filters As Collection

Post by highend »

No problem and thanks a bunch for the donation :beer:
One of my scripts helped you out? Please donate via Paypal

Anklebuster
Posts: 15
Joined: 25 May 2015 21:26

Re: Save Filters As Collection

Post 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

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Save Filters As Collection

Post by highend »

That sounds like the perfect way to handle this!
One of my scripts helped you out? Please donate via Paypal

Post Reply