Author: Laszlo Last Modified: 20100818
This is a way of getting the result of dynamically processed math operations in a string. The main point is not providing a standalone calculator, because there are hundreds of free ones available, but to allow evaluating a math expression typed in an editor or word processor.
Eval(x)
Eval_1(x)
Eval_Choose(n,k)
Eval_fac(n)
Eval_Fib(n)
Eval_FromBin(bits)
Eval_GCD(a,b)
Eval_MAX(a,b)
Eval_MIN(a,b)
Eval_Sgn(x)
Eval_ToBin(n)
Eval_ToBinW(n,W=8)
For the functions's parameters and return value, please see it's source code or the document.
Requires Ahk Version 1.0.48+
The documentation is part of original author`s post at the forum.
I have modified the source (version number contains T for Tuncay)to make it stdlib conform. To accomplish that, I have outcommented lines from autoexecution section and added the prefix Eval_ to all functions. Eval1() becomes Eval_1() and Fib() becomes Eval_Fib() etc...
For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=17058
nonexistent
; #Include Eval.ahk #NoEnv SendMode Input SetWorkingDir %A_ScriptDir% #SingleInstance Force SetBatchLines -1 Process Priority,,High MsgBox % "Eval(""100 + 22 - 55"") expresses to: " . Eval("100 + 22 - 55") MsgBox Next, the script waits for the hotkeys WIN+- and WIN+= (Win and minus key and Win and equal sign). Select any text to express and see the result. One key replaces and the other one append the result. ; Monster by Laszlo #-:: ; Replace selection or `expression with result #=:: ; Append result to selection or `expression ClipBoard = SendInput ^c ; copy selection ClipWait 0.5 If (ErrorLevel) { SendInput +{HOME}^c ; copy, keep selection to overwrite (^x for some apps) ClipWait 1 IfEqual ErrorLevel,1, Return If RegExMatch(ClipBoard, "(.*)(``)(.*)", y) SendInput % "{RAW}" y1 . (A_ThisHotKey="#=" ? y3 . " = " : "") . Eval(y3) } Else SendInput % "{RAW}" . (A_ThisHotKey="#=" ? ClipBoard . " = " : "") . Eval(ClipBoard) Return