Calculator on line
-
A little suggestion for Notepad++,
If notepad++ can do ontime calculation of selected numbers, That would be Amazing !!
for example if I selected a simple line of text like :
250+150+100+500
The result of the calculation will show in status bar…
(If possible)And,
Thanks for the Amazing software Notepad++
Regards,
Monu Kashyap
(India) -
@Monu-Kashyap said in Calculator on line:
If notepad++ can do ontime calculation of selected numbers, That would be Amazing !!
Though I think they’re both 32-bit only.
You can use NppExec with a simple “script”:
::= SET LOCAL ANS ~ $(ARGV) ECHO $(ANS)Then:

Cheers.
-
@Monu-Kashyap said in Calculator on line:
if I selected a simple line of text like :
250+150+100+500Add an
=at the end and select the text of the “equation” in Notepad++ to obtain:
Press Ctrl+c to copy it to the clipboard.
Go to the Run menu and choose Run… and specify something similar to this:

Press the Run button.
When Calculator starts, press Ctrl+v; results:

Save the Run menu entry and bind it to a keycombo if you do this sort of thing frequently.
EDIT: Not sure why I didn’t use your exact numbers in the example! :-)
-
Hello @monu-kashyap, @Michael-vincent, @alan-kilborn, and All,
Here is an other solution which uses a batch file and the
DOScommandset /a-
Open a new N++ tab (
Ctrl + N) -
Run the menu command
Encoding > Convert to ANSI -
Select all the batch file contents, below, and copy them in this new empty file
-
Save it, in the system folder
C:\Windows\System32, ascal.bat
@echo OFF REM *************************************************************** REM * BATCH file "Cal.bat" for MULTIPLE calculations in ONE go * REM * * REM * Type 'cal' WITHOUT parameter or 'cal /?' for EXPLANATIONS * REM *************************************************************** REM ************************************************************************ REM * The TITLE of the DOS windows is changed as "MULTIPLE calculations" * REM ************************************************************************ title MULTIPLES calculations REM *************************************************************************** REM * color <HEX Background><HEX Foreground> sets the COLORS of the CONSOLE * REM * * REM * 0 = Black 8 = Grey * REM * 1 = Dark Blue 9 = Blue * REM * 2 = Forest Green A = Lime * REM * 3 = Dark Cyan B = Cyan * REM * 4 = Dark Red C = Red * REM * 5 = Purple D = Magenta * REM * 6 = Olive E = Yellow * REM * 7 = Light Grey F = White * REM * * REM * You may DELETE this command ( DEFAULT values of CONSOLE are '07' ) * REM *************************************************************************** color 70 REM ************************************************************************** REM * IF call WITHOUT any PARAMETER, JUMP to label "Help" for EXPLANATIONS * REM * * REM * DON'T write "%1"=="" as the PARAMETER may contain DOUBLE quotes * REM * DON'T write !%1==! as, if PARAMETER = /?, it DOESN't work, too * REM ************************************************************************** if %1!==! goto Help REM ************************************************************************ REM * IF PARAMETER = '/?', JUMP to label "Help" for EXPLANATIONS * REM * * REM * DON'T write "%1"=="/?" as the PARAMETER may contain DOUBLE quotes * REM * DON'T write !%1==!/? as, if PARAMETER = /?, it DOESN't work, too * REM ************************************************************************ if %1!==/?! goto Help echo. REM ************************************************************* REM * The DECLARED variables are LOCAL during BATCH execution * REM ************************************************************* setlocal :Deb REM *********************************************************************************** REM * The CURRENT operation in %1 is EVALUATED and RESULT is STORED in VARIABLE %r% * REM *********************************************************************************** SET /a r=%1 REM ********************************************************************************** REM * The CURRENT operation %1 and its RESULT are displayed, with 10 LEADING Spaces * REM ********************************************************************************** echo. && echo %1 = %r% REM *********************************************************** REM * The NEXT typed PARAMETER becomes the FIRST one ( %1 ) * REM *********************************************************** shift REM ********************************************************************* REM * LOOP to the :Deb LABEL for a NEXT calculation if %1 is DEFINED * REM * JUMP to the END of the BATCH, if NO MORE calculation * REM * * REM * DON'T write "%1"=="" as the PARAMETER may contain DOUBLE quotes * REM * DON'T write this SYNTAX !%1==!? as well * REM ********************************************************************* if NOT %1!==! goto Deb echo. && goto :EOF :Help REM *************** REM * HELP menu * REM *************** cls echo. echo. echo ******************************************************************************* echo * BATCH file : CAL.BAT * echo * * echo * SYNTAX : cal[ Op_1[ Op_2[ Op_3[...[ Op_N]]]]] where Op_N = ONE or SEVERAL * echo * ~~~~~~ of the 18 OPERATIONS, below, by DECREASING order of PRIORITY : * echo * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * echo * * echo * () PARENTHESES Grouping * echo * * echo * a DECIMAL value of the DECIMAL number a = a * echo * 0a DECIMAL value of the OCTAL number a = a * echo * 0xa DECIMAL value of the HEXADECIMAL number a = a * echo * * echo * -a OPPOSITE number of number a * echo * ~a Bitwise COMPLEMENT of number a = -a - 1 * echo * !a LOGICAL NEGATION of number a = 0 if a ^<^> 0 * echo * = 1 if a = 0 * echo * * echo * a*b MULTIPLICATION of a by b = a*b * echo * a/b INTEGER QUOTIENT of the DIVISION of a by b = INT (a/b) * echo * a%%b REMAINDER of the DIVISION of a by b = a MOD b * echo * * echo * a+b ADDITION of a to b = a+b * echo * a-b SUBTRACTION of b from a = a-b * echo * * echo * "a<<b" LEFT Shift of b POSITIONS of a = a * 2^^b * echo * "a>>b" RIGHT Shift of b POSITIONS of a = a / 2^^b * echo * * echo * "a&b" Bitwise AND between a and b * echo * "a^b" Bitwise EXCLUSIVE OR between a and b * echo * "a|b" Bitwise OR between a and b * echo * * echo * "var=a" ASSIGNATION of var to a var = a * echo * "varOp=a" ASSIGNATION of (var BINARY Op. a) to a var = var Op. a * echo * ( Ex : x*=7 means x = x * 7 ) * echo * * echo * * echo * a, b, r = INTEGER, in range [-2,147,483,648 +2,147,483,647], with NOTATION * echo * * echo * - DECIMAL : the DIGITS of a NUMBER belong to INTERVAL [0-9] * echo * - HEXADECIMAL : the DIGITS of a NUMBER belong to INTERVAL [0-9] or [A-F] * echo * - OCTAL : the DIGITS of a NUMBER belong to INTERVAL [0-7] * echo * * echo * * echo * NOTES : - The VARIABLE r is the RESULT of the LAST calculation PERFORMED * echo * ~~~~~ ~~~~ * echo * ==) cal a r*r*r...*r ( b TIMES the VARIABLE r ) = a POWER b * echo * * echo * - If an EXPRESSION contains some SPACES, surround it with "......" * echo * * echo * Ex : * echo * * echo * cal "-9 +3" 011*9 "17|22" "12<<5-1" "v=r*=4" (0xba+v)/6 "17&22" "17^22" * echo * * echo *******************************************************************************- Now, in your active
shortcuts.xmlfile, add the line, below, before the end of the</UserDefinedCommands> ••• </UserDefinedCommands>node
<Command name="Multiple Calculations" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /c cal.bat $(CURRENT_WORD) && pause>NUL</Command>-
Close and re-start Notepad++
-
Make a normal selection of that example line
"-9 +3" 011*9 "17|22" "12<<5-1" "v=r*=4" (0xba+v)/6 "17&22" "17^22" -
Execute the menu command
Run > Multiple calculations
Et voilà !!
Notes :
-
Once the results read and, possibly copied in the clipboard, just hit any key to close the
MULTIPLE calculationswindow -
If you don’t like the color of the
DOSconsole, just change the parameters of thecolorcommand or delete it, in thebatchfile ! -
To copy the results to the clipboard :
-
Click anywhere, in that
DOSwindow, with the right mouse button and choose theSelectoption -
Now, by clicking and moving around the pointer you should define a rectangular block, in the same way as a rectangular N++ selection
-
Hit the
Enterkey to copy the contents of this block in the clipboard -
Paste these contents anywhere, in Notepad++ !
-
-
Any selection must contain an even number of double quotes, if any. For instance, the selection
3+4 "5 - 9" 3*5is correct, where as the selection of3+4 "5 - 9 3*5or3+4 "5 - 9are incorrect ! -
Note that a single
shift,logical bitwiseandassignationoperation, as well as any expression containing space chars, needs to be surrounded with double quotes -
Remark that the variable
ralways contains the result of the last performed operation !
Just test it. I hope you’ll like it !
Best Regards,
guy038
P.S. :
I finally don’t think that the conversion to
ANSIis needed, as no character of this batch file is over\x{007f}, anyway ! -
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login