Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f1::
- clipboard = "5+6/2"
- StringReplace, clipboard, clipboard, ",, All ;remove "
- ;change math sysmbols to help with regex
- StringReplace, seconddigit, clipboard, +, plus, All
- StringReplace, thirddigit, clipboard, /, divide, All
- StringReplace, thirddigit, clipboard, -, minus, All
- ;sort data
- RegExMatch(seconddigit,"is)(?<=plus)\S+",seconddigit)
- firstdigit := SubStr(clipboard, 1 , 1)
- clipboard = %firstdigit%
- val := seconddigit + firstdigit
- msgbox, %val%
- Return
- f2::
- FileRead, themath, %A_Desktop%\mathtest.txt
- StringReplace, themath, themath, ",, All
- StringReplace, themath, themath, =,, All
- answer := Eval(themath)
- msgbox, %answer%
- return
- Eval(Expr, Format := FALSE)
- {
- static obj := "" ; par cuestiones de rendimiento
- if ( !obj )
- obj := ComObjCreate("HTMLfile")
- Expr := StrReplace( RegExReplace(Expr, "\s") , ",", ".")
- , Expr := RegExReplace(StrReplace(Expr, "**", "^"), "(\w+(\.*\d+)?)\^(\w+(\.*\d+)?)", "pow($1,$3)") ; 2**3 -> 2^3 -> pow(2,3)
- , Expr := RegExReplace(Expr, "=+", "==") ; = -> == | === -> == | ==== -> == | ..
- , Expr := RegExReplace(Expr, "\b(E|LN2|LN10|LOG2E|LOG10E|PI|SQRT1_2|SQRT2)\b", "Math.$1")
- , Expr := RegExReplace(Expr, "\b(abs|acos|asin|atan|atan2|ceil|cos|exp|floor|log|max|min|pow|random|round|sin|sqrt|tan)\b\(", "Math.$1(")
- , obj.write("<body><script>document.body.innerText=eval('" . Expr . "');</script>")
- , Expr := obj.body.innerText
- return InStr(Expr, "d") ? "" : InStr(Expr, "false") ? FALSE ; d = body | undefined
- : InStr(Expr, "true") ? TRUE
- : ( Format && InStr(Expr, "e") ? Format("{:f}",Expr) : Expr )
- }
- exitapp
Add Comment
Please, Sign In to add comment