Author Topic: Prerequisites of JavaScript  (Read 656 times)

Viking

  • EA User
  • **
  • Posts: 217
  • Karma: +1/-2
    • View Profile
Prerequisites of JavaScript
« on: May 16, 2017, 01:33:46 am »
Hi, because I am not allowed to use MS Script debugger (out of MS-support), I wanted to switch to Javascript. To test the environment I tried a simple script (see below), but EA says, that println is not defined. The script works fine in another environment.

function main() {
       println('Test');
}
main();

So my question is, what are the prerequisites of JS? Can it be disabled and how? Many thanks in advance, V.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 868
  • Karma: +11/-0
    • View Profile
Re: Prerequisites of JavaScript
« Reply #1 on: May 16, 2017, 12:42:41 pm »
Usage of println() would probably depend on the Javascript engine that you are using. The engine that EA uses is based on Mozilla SpiderMonkey (version 1.8 I think), which doesn't seem to know about this function.

The equivilent in EA would be to call Session.Output().  E.g. Session.Output("test");

If you like the style of having println() in your code though, you could just write a little wrapper function like this:

Code: [Select]
function println(message)
{
Session.Output(message);
}

Viking

  • EA User
  • **
  • Posts: 217
  • Karma: +1/-2
    • View Profile
Re: Prerequisites of JavaScript
« Reply #2 on: May 16, 2017, 06:34:13 pm »
Usage of println() would probably depend on the Javascript engine that you are using. The engine that EA uses is based on Mozilla SpiderMonkey (version 1.8 I think), which doesn't seem to know about this function.

The equivilent in EA would be to call Session.Output().  E.g. Session.Output("test");

If you like the style of having println() in your code though, you could just write a little wrapper function like this:

Code: [Select]
function println(message)
{
Session.Output(message);
}

EA still says "Session undefined".

[78862640]      Stack recording threshold set to 3 frames
[78862716]      Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[78862716]      Agent dll found: C:\Program Files (x86)\Sparx Systems\EA\vea\x86\SSScriptAgent32.DLL
[78862716]      Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[78862717]      Agent: Started
[78862768]      Session is undefined

Viking

  • EA User
  • **
  • Posts: 217
  • Karma: +1/-2
    • View Profile
Re: Prerequisites of JavaScript
« Reply #3 on: May 17, 2017, 01:20:18 am »
Any ideas ?  :)

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 868
  • Karma: +11/-0
    • View Profile
Re: Prerequisites of JavaScript
« Reply #4 on: May 17, 2017, 10:56:38 am »
How is EA setup on your machine? Is it installed locally? What operating system are you running?

You mentioned "The script works fine in another environment". What other environment? Was this an installation of EA on another PC? Any differences you are aware of between these installations? What version of EA is installed? Is it the same as yours? Were they both installed the same way?

For example - if your EA was setup using the "Zero Configuration Client" method described on the following page, scripting will not work. See:
http://sparxsystems.com/enterprise_architect_user_guide/13.0/introduction/zero_config_support.html

Viking

  • EA User
  • **
  • Posts: 217
  • Karma: +1/-2
    • View Profile
Re: Prerequisites of JavaScript
« Reply #5 on: May 17, 2017, 08:14:03 pm »
How is EA setup on your machine? -> it's getting installed via DSM.
Is it installed locally? -> yes.
What operating system are you running? -> Win 7 Enterprise
You mentioned "The script works fine in another environment". What other environment? -> private computer with Win 10.
Was this an installation of EA on another PC? -> yes.
Any differences you are aware of between these installations? Win 7 vs Win 10. The EA with problems has been installed by
What version of EA is installed? -> V13
Is it the same as yours? -> Yes.
Were they both installed the same way? -> No. IT department (with problems) vs. me.
For example - if your EA was setup using the "Zero Configuration Client" method described on the following page, scripting will not work. See: http://sparxsystems.com/enterprise_architect_user_guide/13.0/introduction/zero_config_support.html -> no

Isn't there any way to find out how EA has been installed and which features has been installed?

Another solution would be to replace MS Script Debugger with a supported component.
« Last Edit: May 18, 2017, 05:15:01 pm by Viking »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 868
  • Karma: +11/-0
    • View Profile
Re: Prerequisites of JavaScript
« Reply #6 on: May 18, 2017, 11:00:57 am »
So the local installation on your own private Win10 machine is working, but the problematic installation was performed by your IT Department via "DSM", correct? Unfortunately I'm not familiar with this type of installation, but it seems likely that's at least part of your problem. Perhaps this installation method has not properly installed or registered all the prerequisite components, dlls, typelibs, etc.

Just a guess - It may be worth making sure that EA's Type Library has been registered correctly on your system. Open a Command Prompt as Administrator and then run the following commands.
 
CD "C:\Program Files (x86)\Sparx Systems\EA"
EA.exe /register