Script Engine Support

Posted by WillFa on Fri 23 Aug 2002 01:15 AM — 8 posts, 22,242 views.

USA #0
Would it be terribly hard to add PythonScript to the list of scripting engines?

Thanks. :)
USA #1
Doing some research into this:

Python can register itself as another scripting engine, just like perl does. It does get registered to sufficiently function as a Scripting Host engine.

Mushclient seems to have just that list/array/other means of hard coding the supported engines, so trying to kludge a plugin to do Language="Python" gives an error on line 17 :)

I'd really like this, since a lot of the problems that I see people looking to do would be sooooo simple with dictionaries and tuples (and I am not strong in perl at all).

You can get a copy of the language, free of charge, at http://www.activestate.com/Products/Download/Register.plex?id=ActivePython
After installing it, run C:\python22\lib\site-package\win32comext\client\pyscript.py --register to enable the IActiveScript registry entries.

Information that might not help you, but I'm trying to make this as easy as possible. :)

EngineID = Python, ScriptID = pysFile
CLSID of Python = {DF630910-1C1D-11d0-AE36-8C0F5E000000}
Erm, default file extension is .pys for the scripting engine.

Anything else I can do to hopefully get this in 3.27? :)
Thanks again :)
USA #2
Oh yea, forgot to add that the engine does implement the IActiveScriptParse interface, and not the IPersist variants.

If you'd like any help adapting the webpages to include samples of Python, I'd be happy to contribute. :)

Most are very simple to adapt, on a single line it wont appear much different from VBScript. It's Pythons structuring and datatypes that lend to it's elegence.


def OnTrigger (TrigName, Matchedline, arWildCards)
    world.note("Trigger fired", TrigName)
    #commas can concatenate strings, as well as 
    #  separate parameters
    #indentation determines grouping

#blank line ends the sub routine
Australia Forum Administrator #3
Sounds fabulous, thanks for the research.

I'll look into it early next week, and if no problems, do a version which supports Python shortly.

The examples will be harder for me as I've never used Python, but perhaps if you want to take the examplescript file and do a Python version? Of course it'll be hard to test, but perhaps you can test on a pre-release copy for me, or just do what you think *ought* to compile and email me a copy. :)

I'll have to see how array support works, using Jscript needed a bit of a kludge because arrays passed to scripts (eg. the 10 wildcards to a trigger) were a variant array of variants. I'm not sure how Python will handle that.
USA #4
Oops, Typo


def OnTrigger (TrigName, Matchedline, arWildCards):
    world.note("Trigger fired", TrigName)


I accidentally left out the colon at the end of the def
Australia Forum Administrator #5
I am having trouble instantiating the Python scripting engine. In particular, this statement is causing a crash:


m_IActiveScript->AddNamedItem (L"world",
SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE);


It works for the other 3 languages, and after some searching I can't find the solution (so far).

This statement is necessary to expose the "world" object to the scripting engine.

If I take it out the scripting initialisation crashes shortly after, so perhaps there is a problem in the scripting DLL.
USA #6
I used to have similar problems when passing literals instead of variables with the contents.

Dunno if it'll help...


char charWorld[]="world";
m_IActiveScript->AddNamedItem (charWorld,
SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE);
Australia Forum Administrator #7
I had to use:

WCHAR charWorld[]=L"world";


However even that didn't help. After all, it crashed without the entire offending call.