[CLOSED] The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Norn
Posts: 428
Joined: 24 Oct 2021 16:10

[CLOSED] The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line

Post by Norn »

Code: Select all

 $paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
MENU;
 text $paper;
 $paper = formatlist($paper, "d", <crlf>);
 text $paper
It will work if you add the "s" parameter:

Code: Select all

 $paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
MENU;
 text $paper;
 $paper = formatlist($paper, "sd", <crlf>);
 text $paper
Last edited by Norn on 30 Apr 2024 11:24, edited 1 time in total.
Win10, Win11 @100% 2560x1440 22H2

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

Re: The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line

Post by highend »

That's not a bug

For removing duplicates they can't be anywhere in the list but must follow each other. Your's aren't so you need to sort them first

Code: Select all

 $paper = <<<MENU
D:\test\1
D:\test\1.txt
D:\test\1.zip
D:\test\[2]
D:\test\[2](1).zip <-dupe
D:\test\[2](1).zip <-dupe
D:\test\[2].txt
D:\test\[2].zip
D:\test\[2]
D:\test\[2].txt
D:\test\[2].zip
MENU;
 $paper = formatlist($paper, "d", <crlf>);
 text $paper;
One of my scripts helped you out? Please donate via Paypal

Norn
Posts: 428
Joined: 24 Oct 2021 16:10

Re: The formatlist() "d" parameter does not seem to be able to filter duplicate items, a list of one per line

Post by Norn »

Removing duplicates only works on adjacent items, so if the list is not sorted non-adjacent duplicates remain in the list.
I saw the notes. :whistle:
Win10, Win11 @100% 2560x1440 22H2

Post Reply