سؤال

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!

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top