i need a script to find out how many items are selected.
i've tried lots of things, but none of them worked.
can anybody help me?
number of selected items
-
Muroph
- Posts: 561
- Joined: 21 Aug 2007 16:13
number of selected items
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...
-
jacky
- XYwiki Master
- Posts: 3106
- Joined: 23 Aug 2005 22:25
- Location: France
- Contact:
Re: number of selected items
Yep, there no variable for this yet. This should do it (note that it uses the clipboard) :
Code: Select all
// Copy Name(s)
focus l;
#102;
set $list, <clipboard>;
// get last 2 chars, crlf means more than one item
substr $fix, $list, -2;
// nothing at all: we'll add 0 (just like when crlf)
regexreplace $fix, $fix, "^$", ":";
// turn crlf into ":"
regexreplace $fix, $fix, <crlf>, ":";
// if everything but ":" it means no crlf (and no empty), so it was one single name, so we'll add 1
regexreplace $fix, $fix, "^[^:]+$", "1";
// otherwise we'll add 0
regexreplace $fix, $fix, "^:$", "0";
//
// turn all crlf in ":"
regexreplace $list, $list, <crlf>, ":";
// remove everything but ":"
regexreplace $list, $list, "[^:]", "";
// thus we get the number of ":" = crlf = items
strlen $nb_items, $list;
// adding the fix
incr $nb_items, $nb_items, $fix;
// results
msg "$nb_items item(s) selected";Proud XYplorer Fanatic
-
admin
- Site Admin
- Posts: 66279
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: number of selected items
Wow. I think it's time for the getinfo command...jacky wrote:Yep, there no variable for this yet. This should do it (note that it uses the clipboard) :Code: Select all
// Copy Name(s) focus l; #102; set $list, <clipboard>; // get last 2 chars, crlf means more than one item substr $fix, $list, -2; // nothing at all: we'll add 0 (just like when crlf) regexreplace $fix, $fix, "^$", ":"; // turn crlf into ":" regexreplace $fix, $fix, <crlf>, ":"; // if everything but ":" it means no crlf (and no empty), so it was one single name, so we'll add 1 regexreplace $fix, $fix, "^[^:]+$", "1"; // otherwise we'll add 0 regexreplace $fix, $fix, "^:$", "0"; // // turn all crlf in ":" regexreplace $list, $list, <crlf>, ":"; // remove everything but ":" regexreplace $list, $list, "[^:]", ""; // thus we get the number of ":" = crlf = items strlen $nb_items, $list; // adding the fix incr $nb_items, $nb_items, $fix; // results msg "$nb_items item(s) selected";
FAQ | XY News RSS | XY X
-
Muroph
- Posts: 561
- Joined: 21 Aug 2007 16:13
Re: number of selected items
thanks guys!
but i did it myself in the end.
nothing like a good night of sleep (and boring classes
) to help you think, huh?
looks like it has something in common with jacky's script.
but the script i want to use it for will paste the items, so i used #201.
then its just a matter of counting how many colons are on the clipboard.
it will return "1" even if there's nothing selected, but it works for what i need it.
EDIT:
this works perfectly
but i did it myself in the end.
nothing like a good night of sleep (and boring classes
Code: Select all
focus;
#201;
regexreplace $num, "<clipboard>", "[^:]",;
strlen $num, "$num";but the script i want to use it for will paste the items, so i used #201.
then its just a matter of counting how many colons are on the clipboard.
it will return "1" even if there's nothing selected, but it works for what i need it.
EDIT:
this works perfectly
Code: Select all
focus;
//copy names
#102;
set $num, "<crlf><clipboard>";
//this will get rid of the <crlf> at the end of the string. if nothing is selected it will return an empty string
regexreplace $num, "$num", "<crlf>$",;
//replace <crlf> with ":", delete everything else and count the colons
regexreplace $num, "$num", "<crlf>", :;
regexreplace $num, "$num", "[^:]",;
strlen $num, "$num";
msg "$num items";My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: number of selected items
Yes please, I will use this too.admin wrote:Wow. I think it's time for the getinfo command...
XYplorer Beta Club