Using XojoScript

can XOJOScript be used to do this? and if so how (documentation is very confusing)

S=“3*7+12/9”
x=solve_for(s)

where solve_for is an XojoScript the can interpet the text form of the equation on the “fly”?

You can’t call methods/properties defined within a Xojoscript (e.g. solve_for method) from your main app. You need to have the script write the solution to a property in the script’s context.

Minimal function below. Note the the window containing this function will require a double property named “result”. Note also that no error checking is done here. If you have a bad expression, you will need to add a handler for the CompileError event of the xojoScript object.

Function solve_for(expression as string) As double dim script as new XojoScript script.Source = "result = "+expression script.Context = self script.Run return result End Function

You should probably clean expression before sending it to the script, something like expression = ReplaceLineEnding( expression, "_" + EndOfLine ). You don’t want the script doing unexpected things.

I was planning on insureing that the expression was clean and valid before attempting to solve it.

Thanks for the input… let me try some of these things

Check out the Evaluator example, which does this:

Examples/Advanced/XojoScript/Evaluator