Page 1 of 1

JavaScript?

Posted: Sat Sep 03, 2005 4:19 am
by andig
Can I develop in JavaScript for MM? From the script folder it appears that also js should be supported, but I couldn't find any examples/ documentation anywhere. Even simple script doesn't work:

function OnStartup()
{
var UI = SDB.UI;
var Mnu = UI.AddMenuItem( UI.Menu_TrayIcon, -1, 1);
Mnu.Caption = "&Andi";
Mnu.UseScript = Script.ScriptPath;
Mnu.OnClickFunc = "ShowIt";
Mnu.IconIndex = 35;
}

function ShowIt()
{
SDB.MessageBox(SDB.Localize("Select tracks to be exported, please."), mtError, mbOk);
}

Any ideas?

Thanks,
Andi

Posted: Wed Sep 07, 2005 10:26 am
by rk
I am not quite sure, but I think you can just use JScript (instead of Java Script)

Posted: Wed Sep 07, 2005 11:11 am
by Guest
But how? Not even a simple messagebox is working... CHM file only talks about VB.. are the object and function names even the same?

Posted: Thu Sep 08, 2005 2:44 am
by rk
Anonymous wrote:are the object and function names even the same?
Good question. I only do VBS and furthermore are rather new in it. Maybe one of the Gurus can help out ...

Posted: Thu Sep 08, 2005 4:59 am
by jiri
I think that JScript works fine under MM, it's just MessageBox that has a problem. The correct syntax under VBS looks like:

SDB.MessageBox( "Something", mtInformation, Array(mbOk))

I'm not sure how VBS Array() should be written under JS. However, you can always create your own dialogs using UI elements.

Jiri

Posted: Fri Mar 24, 2006 5:47 am
by onkel_enno
Has anyone already written a working JScript for MM?

Posted: Fri Mar 24, 2006 7:46 am
by Steegy
Well, as Jiri said, the above script works except that clicking the added menu item results in an error. But the menu item is added, so the scipt partially works.

The code for the javascript (= JScript) clickhandler should be something like:

Code: Select all

function ShowIt(clickedMenuItem) 
{ 
	SDB.MessageBox(SDB.Localize("Select tracks to be exported, please."), mtError, mbOk); 
} 
The problem is that the clickhandler is executed as a VbScript instead of the JScript. That obviously results in language interpretion errors.

Please devs, take a look at this.
I've been thinking about doing some JScript programming too. (just for the change, these languages are almost the same anyway)

Cheers
Steegy