Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transform selected text to calculation
#1
Is it possible to transform the selected text below (within the code tags) to an calculation
Without using the RunTextAsFunction2 command.

Code:
Copy      Help
(5x3)/2

It's not about the specific calculation stated above, that's just an example.
it could be any legit arithmetic calculation with parentheses.

The selected text could be selected from everywhere (word, notepad, ...etc...)
The first part is easy, that is the following command: _s.getsel
But after that I cannot find a way to do it.

The only other way I found was using the windows commandline in combination with QM

Macro Macro10
Code:
Copy      Help
str calculation="3/2"

if(RunConsole2(F"cmd /c @set /a c={calculation}" _s))
,out "failed"
,end

out F"_s: {_s}"

But this only supports integers not floating point results.
If it is possible, it would be great if could use the solution also in compiled .exe format.
#2
QM does not have an "Eval" function, but can use VBScript or JScript.
Macro Macro2215
Code:
Copy      Help
str s="(5*3)/2+0.2"
out VbsEval(s)
out JsEval(s)
#3
THANK YOU!!


Forum Jump:


Users browsing this thread: 1 Guest(s)