Hi Paul. Thanks for the reference. I'd missed that, but of course that is an ideal example for XojoScript.
Just to clarify, the functionality of the class that I created falls somewhere between the XojoScript example project and Dave Sisemore's RetroBasic expression evaluation capabilities. I didn't want to go full blown computer language processing, but still needed to handle expressions with variables in an efficient way.
The ExpressionEvaluator class deals with expressions in two stages. First, it parses the expression, and creates a symbol table of any variable names that are in the expression, and then creates a compiled pseudo code for later evaluation. Second, a separate evaluation method performs the actual evaluation of the expression. The intention is to spend a bit more processor time in parsing the expression in order to save more time later when evaluating it. This is geared towards my own applications, where the user will enter perhaps one or two expressions, and then they will be evaluated thousands of times. So, the evaluation stage needs to be the most efficient. (This would suggest that XojoScript would be the better route to go, but there are some other subtle but important considerations that affect the decision.)
What initiated all of this is my current project, which is the development of a non-linear multi-variable optimizer. For this, I need the ability to efficiently deal with variables, but I don't need all the full blown features of a programming language expression evaluator (eg. array handling etc.). This class has some useful tools for accessing and changing variable values without much grief.
One of the two examples in the ExpressionEvaluator project file demonstrates the Gauss-Seidel method for solving a set of n linear equations in n unknowns. I think this is a good demonstration showing that a very small amount of external code can be combined with the class to give a very useful result.