Option for Live Filter Box instead of Type Ahead Find

Features wanted...
photoman
Posts: 33
Joined: 29 Jan 2017 14:36

Re: Option for Live Filter Box instead of Type Ahead Find

Post by photoman »

highend wrote:Btw, one way to reduce the necessary tagitems calls:

Code: Select all

    // Decrement stars by one
    $list = "";
    foreach($item, <get selecteditemspathnames |>) {
        $tag = tagitems(1, , $item) - 1;
        if ($tag < -1) { $tag = -1; }
        if (!$tag) { $tag = ""; }
        $list = $list . $tag . "|" . $item . <crlf>;
    }

    foreach($rating, formatlist(regexmatches($list, "^[0-9.,]+"), "des")) {
        $matches = regexmatches($list, "^$rating\|.*?(?=\r?\n)");
        $matches = regexreplace(formatlist($matches, "des"), "^$rating\|");
        tagitems(1, $rating, $matches);
    }
    #485; // Refresh list
It builds a list of ratings for all files and then filters it and goes only over all ratings that need to change
So even if you would use it on 1000 files and e.g. you've only given 3 and 5 stars, tagitems would only
be called two times (one time for 3 and one time for 5)
Wow, that works pretty good. I tested it with a few edge cases. I had to add the '-' to your regular expression so that it would decrement beyond 0.
regexmatches($list, "^[0-9.,-]+"), "des")
Also, it doesn't work when the highlighted items include a file with a rating of 1 and another file with a rating of -1. The rating 1 file doesn't decrement.

But, the speed improvement is excellent!

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

Re: Option for Live Filter Box instead of Type Ahead Find

Post by highend »

Also, it doesn't work when the highlighted items include a file with a rating of 1 and another file with a rating of -1. The rating 1 file doesn't decrement
Does that only happen if both files are in the selection or in general when one is there that has a value of 1?
It's tag should be set to "" (empty) and not "0", correct?
One of my scripts helped you out? Please donate via Paypal

photoman
Posts: 33
Joined: 29 Jan 2017 14:36

Re: Option for Live Filter Box instead of Type Ahead Find

Post by photoman »

highend wrote:
Also, it doesn't work when the highlighted items include a file with a rating of 1 and another file with a rating of -1. The rating 1 file doesn't decrement
Does that only happen if both files are in the selection or in general when one is there that has a value of 1?
It's tag should be set to "" (empty) and not "0", correct?
It happens when they are both selected.
Actually, upon further testing, it seems whenever there is a -1 in any highlighted file, a lot of weird things might happen. Sometimes, some files decrement, other times none of them do. Sometimes all of them work

"" Empty is correct. The way I'm using it will go -1,"",1,2,3, etc...

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

Re: Option for Live Filter Box instead of Type Ahead Find

Post by highend »

Ok, try this (the problem was the absence of a $tag value (even 0), those items weren't processed at all):

Code: Select all

    $list = "";
    foreach($item, <get selecteditemspathnames |>) {
        $tag = tagitems(1, , $item) - 1;
        if ($tag < -1) { $tag = -1; }
        if (!$tag) { $tag = 0; }
        $list = $list . $tag . "|" . $item . <crlf>;
    }

    foreach($rating, formatlist(regexmatches($list, "^[0-9.,-]+"), "des")) {
        $matches = regexmatches($list, "^$rating\|.*?(?=\r?\n)");
        $matches = regexreplace(formatlist($matches, "des"), "^$rating\|");
        if (!$rating) { $rating = ""; }
        tagitems(1, $rating, $matches);
    }
    #485; // Refresh list
One of my scripts helped you out? Please donate via Paypal

photoman
Posts: 33
Joined: 29 Jan 2017 14:36

Re: Option for Live Filter Box instead of Type Ahead Find

Post by photoman »

highend wrote:Ok, try this (the problem was the absence of a $tag value (even 0), those items weren't processed at all):

Code: Select all

    $list = "";
    foreach($item, <get selecteditemspathnames |>) {
        $tag = tagitems(1, , $item) - 1;
        if ($tag < -1) { $tag = -1; }
        if (!$tag) { $tag = 0; }
        $list = $list . $tag . "|" . $item . <crlf>;
    }

    foreach($rating, formatlist(regexmatches($list, "^[0-9.,-]+"), "des")) {
        $matches = regexmatches($list, "^$rating\|.*?(?=\r?\n)");
        $matches = regexreplace(formatlist($matches, "des"), "^$rating\|");
        if (!$rating) { $rating = ""; }
        tagitems(1, $rating, $matches);
    }
    #485; // Refresh list
Yes! That worked. Nice Job :tup:
I finding this to be a pretty useful scripting language. I could see myself tweaking things occasionally.

Post Reply