Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Christer Lindh on July 10, 2014, 06:47:27 pm
-
I'm trying to do some automation in Enterprise Architect using JScript. This is quite new to me, so it's probably a trivial question:
How do I ask for user input? I want to ask the user to enter a string that I can use in the script.
I have searched the EA help and examples and found Session.Input and Session.Prompt. I haven't found any documentation, though. When trying Session.Input nothing seems to happen, and Session.Prompt is only used in the examples with the second argument set to promptOK - I can't find any documentation of what other choices there are...
-
Hi Christer,
I think that's just a JScript Problem. With prompt() method it should work.
see:
http://www.w3schools.com/jsref/met_win_prompt.asp
or other sides.
Helmut
-
Using come of the Cxx languages you may create an own dialogue window which can be used to interact with the user. I'm not sure whether JScript will allow to use that (most likely it won't).
q.
-
When trying to use prompt("Some message") as explained in your linked example, I get an error:
An object is expected
(My translation from Swedish)
I suppose I need an object to call the prompt method on... But I don't have a Window object as in the example, as I'm not in a browser... :(
-
Hi,
the following code works in EA JScript:
var txt = Session.Input("Input value");
Session.Output(txt);
Session is an Object provided and documented by EA (see Online Help).
Helmut
-
When trying Session.Input nothing seems to happen, and Session.Prompt is only used in the examples with the second argument set to promptOK - I can't find any documentation of what other choices there are...
Can you please confirm which program version of Enterprise Architect you are currently running? (See: Help | About EA)
I think there was a fix in EA 11 for Session.Input, not sure if it worked in previous versions. The EA 11 help contents also now contains documentation for the Session Object (See: Help | Help Contents > Automation and Scripting > Scripting > Session Object).
-
I'm running EA 10. So that is possibly the problem then...
My problem is that I'm at a big company and can't decide which version to run... Is there a workaround?
(I do have EA 11 at home, though, so I will try if it works when I get home. :) ).
-
Hi,
sometimes when JScript don't offers a feature which is available in VBScript you can call a VB Script from JScript.
Some times ago I have done it with waiting for a period of time. The example I got somewhere on the internet. You may even dynamically create the VB script and then call it from JScript.
Ok, it might require some digging in the internet.
Helmut
-
Hi,
Just to confirm, something like:
theVariation = InputBox ("Please enter the variation", "", theElement.Name & "#")
Works when using VBScript in Sparx in all versions...so you could have your JScript call a VBScript as Helmut mentions or just re-write in VBScript...
Regards,
Jon.
-
Thanks, I'll try calling VBScript from JScript at work on Monday.
Can just confirm that Session.Input works perfectly in EA 11 when I try it at home. And there is documentation in the help too. :)
Thanks for your help
Christer