Undocumented script commands - Suggestions

Discuss and share scripts and script files...
SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 10:39

calc()
Performs one or more calculations and adds the results. Returns the sum of it all.

Syntax

Code: Select all

calc([term=<clipboard>], [separator="<crlf>"], [flags], [precision=0])
        term:         One or more numbers or mathematical terms (separated by separator).
                      Numbers can be positive or negative, fractional or integer.
                      Defaults to the current clipboard contents.
        separator:    Separator between calculations.
                      Defaults to CRLF (standard Windows linefeed).
        flags:        (bit field)
                  1 = Formats the returned number acc. to system defaults
                      (thousand separators, decimal digits).
                  2 = Formats the returned number with X decimal digits (where X 
                      is specified in the "precision" argument) and no thousand 
                      separators. The format is independent of regional settings.
        precision:    Number of digits after the decimal point in the returned number.
                      Defaults to 2.
                      Can also be negative. A negative precision refers to 
                      rounded digits before the decimal point.
Examples:

Code: Select all

echo calc("16.1, 3.89, -20", ",");      //-0.01
echo calc("123456.789, 1", ",", 0);     //123457,789
echo calc("123456.789, 1", ",", 1);     //123.457,79 (German locale)
echo calc("123456.789, 1", ",", 2);     //123457,79
echo calc("123456.789, 1", ",", 2, 3);  //123457,789
echo calc("123456.789, 1", ",", 2, -3); //123000
// In clipboard:  |  77 * 125 |
//                | 142 * 135 |
//                | 157 * 145 |
echo calc();     // 51560
echo calc(2:=1); // 51.560,00   (German locale)
// In clipboard:  |    19.99  |
//                |      dog  |
//                |           |
//                |    1/100  |
echo calc();     // 20      (the dog and the empty line are ignored)
echo calc(2:=1); // 20,00   (German locale)
Remarks:
  • The terms are calculated, then all results are added to the total result.
  • Any leading or trailing spaces, or empty line are ignored.
  • Anything that's neither a term nor a number is silently ignored (in theory; in reality some invalid terms pass the test and you might get a "Dubious Syntax" warning then).
  • If you live in region where "," is the decimal separator you can use both "," and "." as decimal separators.
History:

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 10:56

highend, I added the DUAL: thing to the locked master list. Feel free to adjust that listing.

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: Undocumented script commands - Suggestions

Post by highend » 26 Jan 2019 11:00

Seen it, but the linked topic doesn't exist :ninja:
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 11:02

heheh, fixed. :ninja:

klownboy
Posts: 2702
Joined: 28 Feb 2012 19:27

Re: Undocumented script commands - Suggestions

Post by klownboy » 26 Jan 2019 13:43

Don removed DUAL quite a while ago. I remember being a little bumbed out about it.

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: Undocumented script commands - Suggestions

Post by highend » 26 Jan 2019 14:08

Yep,
v16.90.0316 - 2016-06-30 18:39
- Dual Locations: Removed the DUAL feature that was experimentally added in
v12.50.0005 - 2013-06-19 14:21. It did not have the desired impact and
unnecessarily complicated the code in various places. It has been kind of
hidden and unofficial anyway since it was never added to the help file.
The app is now lighter and faster.
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 15:12

:oops: d'oh.

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 15:38

Undocumented Variables:

Code: Select all

<curfs>    returns current path's corresponding filesystem
Examples:

Code: Select all

echo <curfs>; // eg, "NTFS"

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 17:58

added get() infos:
pidl, pidlname, pidlpath, pdpath, rs, syscolor

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: Undocumented script commands - Suggestions

Post by highend » 26 Jan 2019 18:57

Thanks for adding them, Sammay :tup:
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Filehero
Posts: 2283
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Undocumented script commands - Suggestions

Post by Filehero » 26 Jan 2019 20:07

@Sammay: is it "just" text mining (release notes) or some sort of reverse engineering?

SammaySarkar
Posts: 4190
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by SammaySarkar » 26 Jan 2019 20:22

well it's kind of text mining, but not just in the release notes.

Filehero
Posts: 2283
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Undocumented script commands - Suggestions

Post by Filehero » 26 Jan 2019 20:56

SammaySarkar wrote:
26 Jan 2019 20:22
well it's kind of text mining, but not just in the release notes.
:tup:

Thanks Sammay and highend for your ongoing efforts! :appl: :appl: :appl:

highend
Posts: 8157
Joined: 06 Feb 2011 00:33

Re: Undocumented script commands - Suggestions

Post by highend » 26 Jan 2019 20:59

All mods can change the locked thread and jupe and Sammy did all the work in the last couple of months :oops:
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Filehero
Posts: 2283
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Undocumented script commands - Suggestions

Post by Filehero » 26 Jan 2019 21:56

highend wrote:
26 Jan 2019 20:59
All mods can change the locked thread and jupe and Sammy did all the work in the last couple of months :oops:
:oops: :oops: :oops:
What an embarassing omission, how could I've forgotten jupe who to my very surprise joined this community already being an XY expert (I call him Mr. Tweak). So jupe, a big kudos to you as well!

Thanks highend.

Post Reply