Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scoping using IActiveScript

32 views
Skip to first unread message

Fred42

unread,
Jan 27, 2010, 7:05:19 PM1/27/10
to
I'm trying to use IActiveScript in a managed (.NET) application. I am
able to get basic script execution to work, but I need to add scoping
for variables and functions.

I'm using IActiveScript.AddNamedItem() to add variable to the script
and then keeping a list of variables that are currently in scope. When
the engine calls IActiveScriptSite.GetItemInfo(), I respond with the
requested variable if it's in scope. This works when the variable is a
class with member functions and the script makes a call such as "var
v0 = Foo.GetBar();", but doesn't work if the variable is a string,
such as "VarString" and it's used as "SomeFunc(VarString). I'm getting
IActiveScriptSite.OnScriptError() called with "Invalid procedure call
or argument".

Any ideas of how to accomplish scoped string variables?

I've also tried creating the variables by executing script such as
"var VarString = 'something'" by calling IActiveScriptParse32-
>ParseScriptText(). This works, but variables added this way appear to
be globally scoped. I investigated using the parameter pstrItemName,
but this seems to only create one scope, not a hierarchical scoping as
is required.

I realize that I'm probably not providing enough detail here, but
there are so many factors involved that I don't want to overwhelm this
posting. I'm happy to provide more specifics and grateful for any
opinions or hints about how to accomplish this task.

0 new messages