CMath plugin for Take Command / TCC / TCC/LE
Version 1.0.1.1 2023-10-12
Charles Dye
Purpose:
This plugin provides an easy way to evaluate math expressions at the command line. Just type a colon, followed by the expression you want to evaluate, and press Enter.
Installation:
To use this plugin, copy CMath.dll to some known
location on your hard drive. (If you are using the 32-bit version of Take Command,
take CMath-x86.dll instead of
CMath.dll.) Load the .DLL file with a
PLUGIN /L
command, for example:
plugin /l c:\bin\tcmd\test\cmath.dll
If you copy the .DLL file to a subdirectory named PlugIns within your Take Command program directory, CMath will be loaded automatically when TCC starts.
Using CMath:
To evaluate a math expression, type a colon followed by the expression. Then press Enter:
:1+2*3
The answer, 7, will be displayed below your expression. It will also
be saved to the environment variable ANS
. You can use this
variable in your next expression:
:ans*2
Just remember that ANS
changes every time you use CMath.
After the second line, ANS
will be 14, not 7.
CMath calls the same function that @EVAL
uses internally.
You can use any operator or function that is legal in @EVAL
:
:log(100)
set r=4
:pi*r**2
You do not need to quote or escape special characters:
:(1+2)*3
:1 << 8
:1024 >> 3
:5 & 9
:5 | 9
:5 ^ 9
The one special character which needs attention is the percent
sign. If you want to use a percent sign as the modulo operator,
you will need to double it. (But it’s probably easier just
to type MOD
.)
:100%%7
:100 mod 7
You do not need a percent sign before environment variables. You do need a percent sign before internal variables and variable functions:
:%_pid =x
:3 * %@dec[foo]
@EVAL
’s built-in functions do not take a percent
sign:
set n=52
set r=5
:fact(n) / fact(n-r) / fact(r)
The Highlight Variable:
The displayed answer will be highlighted. You can customize this
feature by setting an environment variable Highlight
:
rem Disable highlight:
set highlight=none
rem Set the highlight foreground:
set highlight=bright cyan
rem Set both foreground and background:
set highlight=bri whi on blu
rem Numbers are also supported:
set highlight=46
If the Highlight
environment variable is not defined, the plugin will
check the registry for a value named Highlight
of type REG_SZ
.
The plugin will search, in this order:
HKEY_CURRENT_USER\Software\JPPlugins\CMath
HKEY_CURRENT_USER\Software\JPPlugins
Startup Message:
This plugin displays an informational line when it initializes. The
message will be suppressed in transient or pipe shells. You can disable it
for all shells by defining an environment variable named NOLOADMSG
,
for example:
set /e /u noloadmsg=1
Changes:
Version: | Date: | Changes: |
---|---|---|
1.0.1.1 | 2023-10-12 | Updated the plugin’s web page. |
1.0.1 | 2023-07-25 | Added the ability to store the Highlight variable in the registry instead. |
1.0.0 | 2021-10-22 | First release. |
Status and Licensing:
This plugin is © Copyright 2023, Charles Dye. Unaltered copies of the binary and documentation files may be freely distributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.
Download:
You can download the current version of the plugin from http://charlesdye.net/dl/cmath.zip.