Convert string (arithmetic operation)
<p>I need convert <code>"100% - 1"</code> to <code>300 - 1</code> where 300 - canvas width? How to eval (batch) this operation?</p>

<pre><code>//for example:
var value = batch("100% - 1", canvas.width); //Must 299, because canvas.width is 300
var secondary = batch("50% + 10", canvas.width); //Must 160
//where first argument - arithmetic operation, second - relativity value.
</code></pre>

<p>This question is not from the scope of science fiction, but a very serious and real issue.</p>

<p><strong>Update!</strong> But if need just convert percentage?</p>

<pre><code>var value = hack("75%", 300); //Must 255
var operation = hack("30%", 100) + 10; //Must 40
var end = hack("1em", somearg); //EM?
</code></pre>

<p><strong>Update2!</strong> What a will, if i use <code>new Function("a", "b", "return (%%Expression%%)")</code> instead of <code>eval</code>? </p>

<p>For example:</p>

<pre><code>var operation = "90% - 10";
</code></pre>

<p>To:</p>

<pre><code>new Function("a", "return ((a * 90 / 100) - 10)");
</code></pre>

<p>How to made it?</p>
