Author Topic: EA16 JavaScript DLGInputBox bug  (Read 4363 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1194
  • Karma: +36/-2
    • View Profile
    • www.umlchannel.com
EA16 JavaScript DLGInputBox bug
« on: January 20, 2022, 02:48:37 am »
Hello,

I'm using JavaScript to create EA scripts. I need to prompt the user via an input popup that must be prepopulated with an initial value. Using EA 16 new libraries (EAScriptLib.JavaScript-Dialog), I tried the following:

var userInput = DLGInputBox("Question","Title","Default");

Unfortunately I'm getting a "vbe.eval is not a function" error.
Note that Session.Input works but it doesn't let me specify a default value.
Is there a workaround e.g. a suitable JavaScript function to use?

thanks
« Last Edit: February 02, 2022, 06:56:03 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Sunshine

  • EA Practitioner
  • ***
  • Posts: 1211
  • Karma: +108/-10
  • Its the results that count
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #1 on: February 09, 2022, 06:29:39 am »
Sorry not tried it, just used session.input in past. Just wondering if its worth doing a bit of a test with the VB version to see if that works then try the JScript to see if that works. The JScript code looks identical. Just thinking if the VB version works you know the original works. Then trying the JScript one gets you one step closer. It could be something to do with the script engine underneath running that code.  Dunno just a thought.
I'd seek help from Sparx support if I were you should you not get an answer in a couple of days.
Happy to help
:)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1194
  • Karma: +36/-2
    • View Profile
    • www.umlchannel.com
Re: EA16 JavaScript DLGInputBox bug
« Reply #2 on: February 10, 2022, 05:41:39 am »
It works fine both with JScript and VBScript. I contacted Sparx support.

Thanks
 
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Guillaume

  • EA Practitioner
  • ***
  • Posts: 1194
  • Karma: +36/-2
    • View Profile
    • www.umlchannel.com
Re: EA16 JavaScript DLGInputBox bug
« Reply #3 on: May 18, 2022, 04:30:03 pm »
Hi,

Using the latest EA16 build 1604, I tried to use the DLGInputBox function from EAScriptLib.JavaScript-Dialog with the simple Javascript below.
I'm still getting the following error:

EAScriptLib.JavaScript-Dialog error: Exception in COMObject::Create
Classe non enregistrée, Line:26


Code: [Select]
!INC Local Scripts.EAConstants-JScript
!INC EAScriptLib.JavaScript-Dialog

function main()
{
var userInput = DLGInputBox("prompt","titre","default value");
Session.Output(userInput);
}

main();

Is there an alternative Javascript library that would do the job? Session.Input works but is somehow limited and some users complained the dialog window is eventually no longer visible on the screen.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Sunshine

  • EA Practitioner
  • ***
  • Posts: 1211
  • Karma: +108/-10
  • Its the results that count
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #4 on: June 15, 2022, 06:12:16 pm »
Just tried the code below  for fun on V16 B1605 on 64-Bit version unfortunately get the same error.

...

EAScriptLib.JavaScript-Dialog error: Exception in COMObject::Create
Classe non enregistrée, Line:26


Code: [Select]
!INC Local Scripts.EAConstants-JScript
!INC EAScriptLib.JavaScript-Dialog

function main()
{
var userInput = DLGInputBox("prompt","titre","default value");
Session.Output(userInput);
}

main();
...
Happy to help
:)

roybal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #5 on: August 02, 2022, 09:17:51 am »
Hello all,
Could this issue be that the current EA configuration is calling a 32-bit "ActiveX" object which is why the 64-bit version comes back with an error?

I am not sure but it sort of looks like it.

Thanks, Adam

timoc

  • EA User
  • **
  • Posts: 195
  • Karma: +13/-0
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #6 on: August 02, 2022, 08:38:09 pm »
Hello all,
Could this issue be that the current EA configuration is calling a 32-bit "ActiveX" object which is why the 64-bit version comes back with an error?

I am not sure but it sort of looks like it.

Thanks, Adam

I was having similar issues, and found that if you look at the code in the include file you will see:
Code: [Select]
function DLGInputBox( promptText /* : String */, title /* : String */, defaultText /* : String */ ) /* : String */
{
// JavaScript has no intrinsic InputBox method, therefore we have to steal VBs
var vbe = new COMObject("ScriptControl");
vbe.Language = "VBScript";

return vbe.eval( "InputBox(\"" + promptText + "\",\"" + title + "\",\"" + defaultText + "\")");
}

After some experimentation with the Javascript interpreters COMObject( ) method, i started looking at the Javascript EA-Addin functionality.

The JS-Addin feature claims to have EA UI integration for menu items, dialog boxes and such, but I have not yet been able to get it working in EA 16. note the EA16 plugin examples in the example repository seem to be broken (reported).

If you do manage to get the add-in route working, please post..

Update:
After some digging in the JS-Addin documentation, the dialog box i can find is the JavaScript implementation of Session.Input.
Try this in the JavaScript console:
Code: [Select]
Session.Input("Hello")
It may be that any JS-Addin with a UI more complex than a simple dialog-box, requires a diagram with elements and uses the element properties for inputs.





« Last Edit: August 02, 2022, 10:18:28 pm by timoc »

roybal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #7 on: August 23, 2022, 01:09:20 am »
I filed a bug report with Sparx EA about this issue.  Sparx Support confirmed my suspicion that v16 x64 is unable to call the 32-bit COM objects like "Dialog".   

This is disappointing.

From: Sparx Support <support@sparxsystems.com>
Sent: Thursday, August 18, 2022 8:14 PM
Subject: Re: Registered Bug Report - Sparx EA v16 - JavaScript or JScript

Hello Adam,

Thank you for your email.
 
 Unfortunately those scripts are dependant upon 32-bit COM objects and will not work under the 64-bit version of Enterprise Architect. If you need the ability to use these script libraries then you should install the 32-bit version of EA instead.
 
 We don't have any alternative function for providing an InputBox under 64-bit at this time.
 
 Best regards,
....
 Sparx Systems Pty Ltd
 
 
« Last Edit: August 23, 2022, 01:11:16 am by roybal »

roybal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +1/-0
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #8 on: September 14, 2022, 09:22:24 am »
FYI, I have installed the x86/32-bit version of EA v16.   And, the JavaScript COMObject calls work now.

One caution that I believe was mentioned before:

The EAScriptLib JavaScript-Dialog script has a bug at line-29.
  • Original Line: return vbe.eval( "InputBox(\...
  • Corrected Line: return vbe.Eval( "InputBox(\...

The eval command needs to be Eval with a Capital E.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1194
  • Karma: +36/-2
    • View Profile
    • www.umlchannel.com
Re: EA16 JavaScript DLGInputBox bug
« Reply #9 on: September 23, 2022, 06:10:33 pm »
Thank you for the update.
I confirm that it works in EA16 32 bits with the vbe.Eval fix copied locally. Hopefully this code will be fixed in the next EA16 build.

For the 64 bits version I wonder if there is going to be an alternative to open dialog windows and others using Javascript. Otherwise, JScript will remain the valid alternative before this is addressed.


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11935
  • Karma: +464/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA16 JavaScript DLGInputBox bug
« Reply #10 on: September 23, 2022, 06:38:01 pm »
Otherwise, JScript will remain the valid alternative before this is addressed.

Or good old VBScript :)

Geert

PeteC

  • EA User
  • **
  • Posts: 69
  • Karma: +1/-0
    • View Profile
Re: EA16 JavaScript DLGInputBox bug
« Reply #11 on: September 27, 2022, 05:31:31 pm »
Otherwise, JScript will remain the valid alternative before this is addressed.

How is Jscript better? I have a script in Jscript and have come across the exact same problem (importing the JScript-Dialog fails with an almost identical error: EAScriptLib.JScript-Dialog error: Automation server can't create object, Line:26).

Is there an alternative method in Jscript that I am not aware of that will provide equivalent input? Otherwise I'll have to fallback to the Session.Input option.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1194
  • Karma: +36/-2
    • View Profile
    • www.umlchannel.com
Re: EA16 JavaScript DLGInputBox bug
« Reply #12 on: September 27, 2022, 06:54:30 pm »
My bad, I assumed it was fine with JScript.
Even though I've extensively used VB, I tend to move to JScript or Javascript as I find the code easier to maintain. Clients also prefer to use these languages.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com