Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: thais on January 10, 2011, 06:24:42 am

Title: JScript input box
Post by: thais on January 10, 2011, 06:24:42 am
Hello,

I want to write a Project Browser script in JScript and therefore I need inputs from the user.
How is it possible to write a input dialog box?

thanks!!
Title: Re: JScript input box
Post by: mrf on January 10, 2011, 08:55:18 am
Unfortunately JScript has no intrinsic input box. You can use this trick though:

Code: [Select]
function InputBox( promptText /* : String */, title /* : String */, defaultText /* : String */ ) /* : String */
{
      // JScript has no intrinsic InputBox method, therefore we have to steal VBs
      var vbe = new ActiveXObject("ScriptControl");
      vbe.Language = "VBScript";
      
      return vbe.eval( "InputBox(\"" + promptText + "\",\"" + title + "\",\"" + defaultText + "\")");
}

Which creates a temporary VBScript engine, calls InputBox and returns the result to your JScript.