Of course, you can use external tools for calculations. All you need to do is to select the text which contains some mathematical expression and call NppExec's script which would allow to calculate it.
For example:
set AWK_EXE = C:\tools\gawk\gawk.exe "$(AWK_EXE)" "BEGIN { print $(CURRENT_WORD) }"
This simple script allows you to calculate such expressions as "1 + sin(3)/4" or "(2 + 0x10)*3" etc.
You can modify the file "do.awk" from previous example [4.6.1] in order to calculate an average value of numbers given as the following table:
1. 552 2. 554 3. 549 4. 551
Here is the AWK script (i.e. the content of "do.awk") which calculates an average value of numbers in the second column:
BEGIN { Sum = 0 N = 0 } NF == 2 { Sum += $2 ++N } END { print "avg = " Sum/N " (Sum = " Sum ", N = " N ")" }
Now, all you have to do is to select the given table (see above) in Notepad++ and execute NppExec's script "do.awk on selected text". You will see the following output in NppExec's Console:
avg = 551.5 (Sum = 2206, N = 4)
Of course, you can use other external tools for calculations of selected expressions or table data. The output of such external tools will be shown in NppExec's Console. Also you can redirect such output into a text file and then open that text file in Notepad++ [4.5].
NppExec ver. 0.4 introduces built-in calculator abilities provided by Function Parser (fparser). For example:
// calculate math expression on the current line // usage: type math expression in the editor and run this script NPP_CONSOLE ? // don't show the Console if it's hidden SCI_SENDMSG SCI_GETCURLINE 100000 @"" // get current line set ans ~ $(MSG_LPARAM) // try to calculate SCI_SENDMSG SCI_LINEEND // go to end of line SCI_SENDMSG SCI_REPLACESEL 0 " = $(ans)" // add the result
Type "help set" for more details.
See also: Calculations, strlen and so on [3.8.4].