Tcl, the Tool Command Language, is the leading language for embedding into applications to automate tasks (precisely what MUclient scripting is). It is used by NBC for video scheduling, by Oracle and Sybase for testing, by NASA in the Mars Pathfinder probe, by AOL for their generated web content, and in countless applications that use scripting. It is thread-safe, has a very simple syntax, and has built-in functionality for disabling all "non-scripting" type functionality (like file manipulation, etc.) with one line of code. VMoo and TkMOO already have this functionality, to great success.
If you added an option to "trust" a script and allow it to use Tk (the accompaying graphics toolkit) and file i/o, you could even allow TkMOO plugins to run under MUclient. Hell, if you did this I'd personally write the adapter code to make it work - I've gotten authorization to write an adapter for his plugin code for my own client from the author, and presumably he'd be OK with one for MC too.
However, if a built-in COM interface (rather than Tcl's very easy native embedding system) is necessary for whatever reason , you're going to need to use the Optcl library for COM at http://www.sys.uea.ac.uk/~fuzz/optcl/default.html.
However if you are going to use square brackets and forum codes, you should really use MUSHclient's notepad to "escape forum codes" so that things like [b] don't get rendered as bold (that is, in the code).
I am having trouble getting it to register the script engine, which version of tcl do you recommend I install? I tried ActiveTcl 8.3.5.0 however it didn't register the script engine, and I am in the dark a bit about how to get it all working. For instance, trying to open the register.tcl file in Wish (should I be doing this?) gives messages about:
% 0x80029c4a {Error loading type library/DLL.}
Trying regsvr32 on the tclscript.dll gives messages about "the DllRegisterServer entry point was not found".
OK, I installed 8.4.2.0 which seemed to go OK, and registered the script engine, which appears in the Registry.
However when trying to initialise the script engine I now get an access violation.
This is exactly the same code that successfully opens VBscript, Jscript, Perlscript, and Python.
I'm not going to spend too much time on it now, unless you can point me to some place that says what I am supposed to do differently with Tcl compared to the others. The error itself seems to be in Tcom.
I have done a minimal test file that, in a single file, demonstrates the problem. Copy between the lines and paste into (say) test.cpp and compile under Microsoft Visual C++.
By changing the defines (line 4 on) you can test different script engines. Uncomment #define PERLSCRIPT for instance, and comment out #define TCL.
In *every* other case (you can try them) the script engine initialises, and runs, displaying a message box. Here is the example from Perlscript, also from ActiveState:
I tested it, and it crashes as I expected. I would expect BTW that on a syntax error I would get a nice error message, after all syntax errors would be common enough, and should not cause "catastrophic failure" or an access violation.
Meanwhile, perhaps you can interpret the "message box" idea into Tcl for me. How would I create a COM object (like in the examples in the other languages) or put up a message box?
Quote: In article <dbb6dfe6.0305132012.402608d3@posting.google.com>,
Alex <stopm@attbi.com> wrote:
>Everything after this line is Nick's words.
>
>I have done a minimal test file that, in a single file, demonstrates
>the problem. Copy between the lines and paste into (say) test.cpp and
>compile under Microsoft Visual C++.
You didn't mention what version of tcom you are using. The Tcl Active
Script engine in the tcom distribution is still in an experimental
state. The tcom-3.9b8.zip beta version from the
http://www.vex.net/~cthuang/tcom/ Web site includes an update to the
Tcl Active Script engine.
The test program doesn't crash, however you haven't replied to my earlier question about how to do, say, a message box, so all I can say is that it doesn't crash, not that it does anything very spectacular.
However MUSHclient still does crash, bearing in mind that the exact same code works fine for the other 4 scripting languages.
I think it is a bit obscure to have to download tcl from ActiveState and then add in bits and pieces from other sites, I doubt everyone will want to do that.
Sounds like it is not fully implemented. The exact same code works for other languages, here is the part in question ...
// set state to started
if (ShowError (m_IActiveScript->SetScriptState (SCRIPTSTATE_STARTED),
"starting script engine"))
return true;
// connect outbound objects (ie. world)
if (ShowError (m_IActiveScript->SetScriptState (SCRIPTSTATE_CONNECTED),
"connecting script engine"))
return true;
// get script engine dispatch pointer
if (ShowError (m_IActiveScript->GetScriptDispatch (0, &m_pDispatch),
"getting script engine dispatch pointer"))
return true;
It got through everything (starting, connecting) until getting the dispatch pointer (which is needed to call scripts). That was the last thing it had to do. The same code works for Perl, Python, VBscript, JScript.
Configuring Tcl seems to be a pain, I'm learning COM stuff and I might try it myself and tell you how if I figure it out. Feel free to take it out for now ;)
If you mean other languages, I think it's pretty reliable on average. Though there aren't that many commonly used languages that you haven't already done <g>