1 Reply Latest reply on Mar 16, 2009 6:11 AM by Ned Murphy

    How to convert from string to expression?

    chris2.718
      ActionScript 2

      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 expressions.

      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".

      Any help would be greatly appreciated.