I need to convert a string such as "x*y+2" (from an input
text field) into an expression x*y+2, so that it can be evaluated
normally, eg f=x*y+2. The variables x and y are already defined and
can have various values; I need to evaluate the strings as
I have tried f=Number("x*y+2") but it seems to work only when
the string is actually a number such as "1.2e-4".
I may be wrong, but I don't think there's anything that can
evaluate a string as an equation. You would need to create your own
parser that breaks the string down and evaluates each character and
processes things logically.