Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run-time evaluation of values in DelphiWebScript

My delphi application runs scripts using JvInterpreter (from the Jedi project).

A feature I use is runtime evaluation of expressions.
Script Example:

[...]
ShowMessage(X_SomeName);
[...]

JvInterpreter doesn't know X_SomeName. When X_SomeName's value is required the scripter calls its OnGetValue-callback. This points to a function I handle. There I lookup X_SomeName's value and return it. Then JvInterpreter calls ShowMessage with the value I provided.

Now I consider switching to DelphiWebScript since it has a proper debug-interface and should also be faster than JvInterpreter.

Problem: I didn't find any obvious way to implement what JvInterpreter does with its OnGetValue/OnSetValue functions, though.

X_SomeName should be considered (and actually is, most of the time) a variable which is handled by the host application.

Any Ideas?

Thanks!

like image 559
Folkert Hasenlust Avatar asked Nov 12 '22 12:11

Folkert Hasenlust


1 Answers

You can do that through the language extension mechanism, which has a FindUnknownName method that allows to register symbols on the spot.

It is used in the asm lib module demo, and you can also check the new "AutoExternalValues" test case in ULanguageExtensionTests, which should be closer to what you're after.

like image 117
Eric Grange Avatar answered Nov 15 '22 05:11

Eric Grange