- Aug
- 2,134
- 92
I like the way that one can do simple math from the PowerShell command line, example;
Using the following alias;
...I can now do;
...from the TCC Command line.
Again, this is only for simple math, not for log(), fact(), MOD, etc.
When I enter an UNKNOWN_CMD, for example;
...which is not pretty, but it works.
The next evolution of doing simple math from the TCC command line involved changing the alias to;
...and creating UNKNOWN_CMD.BTM
...returns;
...which gives me more info than;
...but it works okay for me, as I use several AutoHotkey scripts for my non-conforming typing, for example;
...which, when I type dre is automatically changed to dir.
Feel free to make modifications to this procedure for TCC command line math, but if you do, please share your modifications.
Joe
Code:
PS E:\utils> 52*4
208
Using the following alias;
Code:
e:\utils>alias unknown_cmd
echo %@eval[%@filter[0123456789.*+-/\,"%$"]]
...I can now do;
Code:
e:\utils>52*4
208
Again, this is only for simple math, not for log(), fact(), MOD, etc.
When I enter an UNKNOWN_CMD, for example;
Code:
e:\utils>dze
TCC: No expression ""
...which is not pretty, but it works.
The next evolution of doing simple math from the TCC command line involved changing the alias to;
Code:
alias unknown_cmd=e:\utils\unknown_cmd.btm
...and creating UNKNOWN_CMD.BTM
Code:
@setlocal
@echo off
unalias unknown_cmd
set UseEval=N
iff %@isalpha[%$] eq 0 then
iff %@isfloat[%$] eq 0 then
iff %@isalnum[%$] eq 0 then
set UseEval=Y
endiff
endiff
endiff
iff %UseEval eq Y then
echo %@eval[%@filter[0123456789.*+-/\,"%$"]]
else
on error gosub Catch
%$
endiff
alias unknown_cmd=%_batchname
endlocal
quit
:Catch
echo ?: %?
echo _?: %_?
echo _Syserr: %_syserr
echo @isalpha: %@isalpha[%$]
echo @isfloat: %@isfloat[%$]
echo @isalnum: %@isalnum[%$]
Return
...returns;
Code:
e:\utils>dze
?: 0
_?: 0
_Syserr: 536870913
@isalpha: 1
@isfloat: 0
@isalnum: 1
...which gives me more info than;
Code:
TCC: No expression ""
...but it works okay for me, as I use several AutoHotkey scripts for my non-conforming typing, for example;
Code:
e:\utils>type dre.ahk
:*:dre::dir
...which, when I type dre is automatically changed to dir.
Feel free to make modifications to this procedure for TCC command line math, but if you do, please share your modifications.
Joe