5 Replies Latest reply on May 7, 2007 8:41 AM by EvHes

# Computing a String

Does anyone can tell me where I can find a function who computes a string to a single value:

I.e:
Var A : String = “100*29+(34*399+90)”;
Var B : Number=SomeComputeFunction(A);

Thanks!
• ###### 1. Re: Computing a String
as far as i know you can't compute a string since it's not a number
val = "100";
you can try

parseInt(val); // makes an interger #

or alse make the computation in the function()

function calc(val1, val2) {
var val1 = parseInt(val1);
var val1 = parseInt(val2);
val = val1*val2;
return val;
}
output = calc(100, 40);

h.i.h.
ML
• ###### 2. Re: Computing a String
You are right, there is no standard function in Flash AS.
I did it once in Pascal and it was called Evaluator.

This can be very complex because of the parentheses ( .

So just wit parseInt won't work.

• ###### 3. Re: Computing a String
correct.
you can however also use eval();

so val = eval("100"+50);
you get 150 as an int.
• ###### 5. Re: Computing a String
YES!!!

Thank you a lot!!