Provides a mathematical expression evaluator. Mathematical expressions can be passed to it as a string, and solved. This allows mathematical expressions to be stored as strings, and be generated or altered at run-time.
Basic Usage In the most basic usage, variables are loaded into the a new expreval, and an expression is evaluated. The output variables can then be read.
// create expression var eval = expreval_create(); // set up variables expreval_write_variable(eval, "a", 123); // evaluate expression (intermediate variables are created automatically expreval_evaluate(eval, "b=2*a;c=sin(b)"); // grab output variables var retval = expreval_read_variable(eval, "c"); show_debug_message("Returned value: " + string(retval)); expreval_destroy(eval);
Multiple expressions can be evaluated, by separating them with a semicolon in the expression string.
Any temporary or output variables used in the expression will be automatically created, and made available for reading. Referencing an undefined variable will cause an error.
exprevals must be destroyed after they are no longer used to avoid a memory leak.