ActivePerl/Python: Problems accessing variables via IActiveScript::GetScriptDispatch

James Hugard james_hugard at hotmail.com
Thu Feb 13 10:45:24 EST 2003


I have created generic MS Windows Scripting support via IActiveScript for my
application. The app runs Jscript, VBScript, PerlScript, and PythonScript
very well. Jscript is the primary script language, but the application must
be compatible with VBScript, PerlScript and PythonScript in the event we
wish to license these as scripting engines in the future (i.e., I have
internally advertised support for these as available scripting language,
should we choose to use them).

As part of the design, I must provide host-application (C++) access to
functions, variables and objects created by each of these script engines, in
addition to host-defined objects. The normal means of doing this is via
IActiveScript::GetScriptDispatch.

This works quite well for Jscript and VBScript -- I can access functions,
variables, classes, objects, and object properties when these are created by
script.

However, there *are* issues accessing these things when created in
PerlScript and PythonScript. From limited experimentation, the following
things appear to be supported and unsupported in PerlScript and
PythonScript:

PERLSCRIPT
   - Supports retrieving and calling global procedures
   - No support for accessing global variables
   - No support for accessing structures and structure members
   - No support for accessing class (module) instance data

PYTHONSCRIPT
   - Supports retrieving and calling global procedures
   - Supports accessing global variables (see notes)
   - No support for accessing class objects or members (see notes)

Would someone be kind enough to either verify that these are real
limitations of these two engines, or indicate that I am just doing something
wrong in my code and it works fine in yours? Perhaps I am not asking for the
variables using the proper name? I am particularly interested in accessing
script-created objects and object properties - this is important to the
application design

Thank you very much for your help!

NOTES
PythonScript returns E_NOTIMPL for both variables and class instances when
attempting access via pDispatch->Invoke( ..., DISPATCH_PROPERTYGET, ...).
However, calling pDispatch->Invoke( ...,
DISPATCH_PROPERTYGET|DISPATCH_METHOD, ...) seems to work fine for variables,
but still returns E_NOTIMPL when attempting to access an object (class
instance) or object properties.

Neither works for PerlScript: in fact, PerlScript does not get past
pDispatch->GetIDsOfNames(), which returns DISP_E_UNKNOWNNAME. This leads me
to think that perhaps PerlScript requires some additional syntactic sugar to
access variables and object member. None of the following work: "varName",
"main::varName", "main::$varName", or "$varName". However, I can access
procedures just fine with the same code. Am I doing else something wrong
here? Do I need to specify the variable name differently?

If unsupported, are there plans to provide this capability in future
versions of PerlScript or PythonScript?

James
_____________________________________________________________
"Perfection is reached, not when there is no longer anything more to add,
but when there is no longer anything to take away."
-- Antoine de Saint Exupery
_____________________________________________________________
James Hugard, Software Consultant
James.Hugard at hotmail.com
_____________________________________________________________






More information about the Python-list mailing list