scripting - using ms jscript

Posted by Pompey1 on Thu 27 Mar 2008 02:51 AM — 6 posts, 30,160 views.

#0
I have the following script to read a nowplaying text file generated by an amarok plugin. The file is created with the correct name and in the correct directory.

function ReadNowPlaying() {
var fname =
"c:\\program files\\mushclient\\worlds\\nowplaying.txt";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var textStream = fso.OpenTextFile( fname, 1 );

while (!textStream.AtEndOfStream) {
var dataLine = textStream.ReadLine();
world.note(dataLine);
}

textStream.Close();
}

I've got the scripting dlls jscript.dll and scrrun.dll in the "/home/<username>/.wine/drive_c/windows/system/" directory.

The text file is being generated as: "/home/<username>/.wine/drive_c/program files/mushclient/worlds/nowplaying.txt"

I get an error message:

Error number: -2146827859
Event: Execution of line 1460 column 3
Description: Automation server can't create object


Called by: Immediate execution

when I try and invoke the script function with immediate execution, the line number points to the line "var fso = new ActiveXObject("Scripting.FileSystemObject");" but that line is copied straight out of the ms help file for the scripting host.

I'm guessing I need to tweak something to access this object under wine, can anyone suggest what I need to tweak?

Pompey1
Amended on Thu 27 Mar 2008 02:56 AM by Pompey1
Australia Forum Administrator #1
Personally I would script using Lua, which has a built-in interface to MUSHclient. All the other scripting languages use COM and are less reliable under Wine.

However if you insist on trying to use Jscript, try running MUSHclient without the /wine command-line option, if you are using it.
USA #2
Lua also has wonderful IO for text files. I am not sure if you can get jscript working with ActiveX controls through Wine. Heck, I even have issues with ActiveX on XP at work several times a week.
#3
Yes, the question now is whether I want to re-code 1400+ lines of script from javascript to lua just so I can spam my amarok nowplaying music track at other mud users. :)

Pompey1
Australia Forum Administrator #4
You know, if you just want to do one specific thing in Lua, you can make a plugin. Each plugin can be written in a different language.

One technique is for your main script to send a command which the plugin picks up as an alias. For example:

  • Main script does: world.Execute ("nowplaying foobar")
  • Plugin has an alias matching: nowplaying *
  • Plugin opens the file needed by the wildcard (eg. for foobar) and displays/sends the appropriate things

#5
I tried that, but I'm having problems .... I decided to convert the whole script to lua - should be an interesting exercise.

Pompey1