Minor scripting related wishes (a generic thread)

Features wanted...
Post Reply
admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by admin »

TheQwerty wrote:
SkyFrontier wrote:Can inputselect have sorting options?
At least "sort by name" and "sort by modification date" with respective ascending/descending options would be great. The more sorting modes can be implemented, the better.
Thanks!
(I'm yet to figure out which order it uses to display my files...)
In the same vein I'd like to see a function that sorts data.

Sort( List, [Mode], [Dir], [Delimiter] );

Mode: S = Case Sensitive; I = Case Insensitive; N = Numeric (1,2,10 instead of 1, 10, 2)
Dir: 1 = Ascending, 0 = Descending
Delimiter: How List should be split, default '|'.
Might even be nice to include an option to delete duplicate items but that's less important.

Then you could combine this with a Report to sort the data with whatever field you like before giving it to InputSelect.
Sweet, I added an improved :P version of this idea.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

admin wrote: Didn't they have good enough file managers on the planet you are coming from? :wink:
...so now you may have a better picture of how valuable your software really is, I presume...? 8)
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

admin wrote:Sweet, I added an improved :P version of this idea.
A bit more complicated than what I was aiming for since the quoting & trimming could already be accomplished with (Regex)Repalce, but that should make it easier for some of the non-scripters. Looks good!

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

Code: Select all

v9.70.0001 - 2010-11-06 16:12
    + Scripting got a new function.
      Name:   formatlist
      Action: Formats a list of items.
...
I'd like to thank you.
But it would be really useful if another parameter could be added: something to display duplicates only (of course I'm talking on displaying/counting perhaps items out of a TEXT list which supports duplicated entries). Perhaps this can provide a way to report separately such duplicated items, then removing them via the surprising d = remove duplicate items parameter. I think it makes sense...
(not to mention that I'd really like to be able to sort stuff by dates, modified at least, but - s = sort ascending [by default case-insensitive: A==a] brings some order to chaos, no doubt on that!)
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

...is it just an impression or I really can't have a total count for selected items' size via script?
If this is possible, can someone please enlighten me on how? My goal is to have a simple way to compare (display simultaneously via "msg", "echo" or "text") selected items' sizes on both panes at any time.
Thanks!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by admin »

SkyFrontier wrote:...is it just an impression or I really can't have a total count for selected items' size via script?
If this is possible, can someone please enlighten me on how? My goal is to have a simple way to compare (display simultaneously via "msg", "echo" or "text") selected items' sizes on both panes at any time.
Thanks!
I'll add it.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

SkyFrontier wrote:...is it just an impression or I really can't have a total count for selected items' size via script?
If this is possible, can someone please enlighten me on how? My goal is to have a simple way to compare (display simultaneously via "msg", "echo" or "text") selected items' sizes on both panes at any time.
Thanks!
Is this script not part of your library? http://www.xyplorer.com/xyfc/viewtopic. ... 869#p35869

Would be easy to convert it to work on just the selection instead of full branch...
EDIT: Ugh.. it's too early... I suppose you probably want it to work on folders as well so it's not as nicely done.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

TheQwerty wrote: EDIT: Ugh.. it's too early... I suppose you probably want it to work on folders as well so it's not as nicely done.
Yep, you' right! :wink:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

admin wrote:
SkyFrontier wrote:...is it just an impression or I really can't have a total count for selected items' size via script?
If this is possible, can someone please enlighten me on how? My goal is to have a simple way to compare (display simultaneously via "msg", "echo" or "text") selected items' sizes on both panes at any time.
Thanks!
I'll add it.
Playing a bit while we don't have the official way - can someone tell me how to get the conditional commands working at the section $f;?

Code: Select all

   $type = confirm("Only files or folders too?<br><br>OK for Files only,<br>Cancel for Folders too.");
   $f = ($type) ? 'focus' : '#487';
   "$f"; //display folder sizes, if it's the case
//NOT works!   setting "ShowFolderSizeInList", 1;
//   #487;
   $c= report ("{Size B}+", 1); $t= substr ($c, 0,-1); replace $t, $t, "-","0"; $t= eval ($t);
   focus pi;
   $c2= report ("{Size B}+", 1); $t2= substr ($c2, 0,-1); replace $t2, $t2, "-","0"; $t2= eval ($t2);
   setting "ShowFolderSizeInList", r; //does NOT unset option set by #487!  :? 
   Echo("File sizes on original pane are: $t bytes, <crlf>while in the opposite pane are $t2 bytes.<crlf>-Have a nice day!");
It seems to be a simple problem, but I'm yet to get this working.
...wondering: will report/eval really sum up all values for both files+folders? Stay tuned for the next chapter, boys and girls! :wink:
---
Here's a simple script that works for files only on both panes, in case of anyone gets interested:

Code: Select all

   $a = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
   focus pi;
   $b = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
   Echo("File sizes on original pane are: $a bytes, <crlf>while in the opposite pane are $b bytes.<crlf>-Have a nice day!");
---
Hint: 1st script work for selected items, 2nd for all items displayed on list.
Thank you!
EDIT: Improved the test code a bit. Now it calculates selections containing folders, too - but still doesn't work as a "confirm" result...
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

This is an attempt to circumvent the problem described on my previous post (trying to run two different scripts out of a "confirm: ok/cancel" dialog).
It makes sense to my newbie-scripter mind.
-why it doesn't work?! :|
-why setting "ShowFolderSizeInList", 0; is not refreshing folder to NOT display folder size in list at the end of the operation in "_ONE"?

Code: Select all

   $x = Sub "_ZERO";
   $y = Sub "_ONE";
   $type = confirm("Only files or folders too?<br><br>OK for Files only,<br>Cancel for Folders too.");
   $f = ($type) ? '$x' : '$y';
   "$f";

"_ZERO"
   $a = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
   focus pi;
   $b = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
   Echo("File sizes on original pane are: $a bytes, <crlf>while in the opposite pane are $b bytes.<crlf>-Have a nice day!");

"_ONE"
   #487;
   focus pi;
   #487;
   $c= report ("{Size B}+", 1); $t= substr ($c, 0,-1); replace $t, $t, "-","0"; $t= eval ($t);
   focus pi;
   $c2= report ("{Size B}+", 1); $t2= substr ($c2, 0,-1); replace $t2, $t2, "-","0"; $t2= eval ($t2);
   setting "ShowFolderSizeInList", 0;
   Echo("File sizes on original pane are: $t bytes, <crlf>while in the opposite pane are $t2 bytes.<crlf>-Have a nice day!");
Thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Minor scripting related wishes (a generic thread)

Post by Stefan »

I don't checked your whole script,
but the last command in the first section should be >sub "$f";<

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

Hi, Stefan.
No go.
The scripts work as expected individually, but I'm yet to find a way to launch them as intended - ok for the first, cancel for the second - or anything else on the same approach (a little description with 2 buttons to launch one or another script).
Thanks.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Minor scripting related wishes (a generic thread)

Post by Stefan »

Oh, there is the "sub" :oops: now i see it.


You mean something like

Code: Select all

$answer = confirm("Only files or folders too?<br><br>OK for Files only,<br>Cancel for Folders too.")?"_ZERO":"_ONE";
    sub $answer;

"_ZERO"
   msg "zero Files";

"_ONE"
   msg "one Folder";
And more generally example for reference:

Code: Select all

$answer = confirm("Make your choice...")?"OK":"Cancel";
   sub "_$answer";

"_OK"
  msg "You pressed OK, how nice of you ;-)";

"_Cancel"
  msg "He! why did you pressed Cancel?";

But, BTW, we are in the wrong thread (" Minor scripting related wishes (a generic thread)") i think.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

Stefan wrote:But, BTW, we are in the wrong thread (" Minor scripting related wishes (a generic thread)") i think.
And to get it back to the topic... is there anyway Format() could be expanded to convert sizes (bytes) to the various units?

Would be nice to eliminate having to do the math & juggling:

Code: Select all

    if     ($exp >= 1099511627776) { $suffix = "TB"; $exp = $exp / 1099511627776; }
    elseif ($exp >= 1073741824)    { $suffix = "GB"; $exp = $exp / 1073741824;    }
    elseif ($exp >= 1048576)       { $suffix = "MB"; $exp = $exp / 1048576;       }
    elseif ($exp >= 1024)          { $suffix = "KB"; $exp = $exp / 1024;          }
    else                           { $suffix = "B";                               }

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Minor scripting related wishes (a generic thread)

Post by SkyFrontier »

Stefan wrote: But, BTW, we are in the wrong thread (" Minor scripting related wishes (a generic thread)") i think.
Oh, yes, I noticed - the thing was the script was in the context of the wish (which was of relevance) and I decided to keep it rolling instead of just opening another thread just for the sake of it. Made sense to me like that.
Now that we have a final script out of the wish, here's the proper thread for any further discussion: Display Sum of Files and Folders' Sizes on both Panes

Thank you also for the generic/didactic version of your answer, Stefan! I always try to keep in mind that such stuff will remain for future usage of anyone stumbling upon the forums (just wish I had the time to make more comments on my own scripts on that very fashion... :oops: ).
Again, thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply