Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: MrSnow on March 01, 2019, 08:28:18 pm
-
Hi,
I am working on extracting all information from a class diagram to create a basis for a JSON Schema for the specific diagram i EA. I am using JScript "inside" EA and working up against a database. I am getting an error using this line of code:
"var fh = fopen("c:\\MyFile.txt", 3); // Open the file for writing
Therefore my questions are:
- Is what I am asking for possible to do scripting from inside EA?
- If not, what would be the best way to create a console application that connects to a specific package inside an EA database?
All help and comments are appreciated!
-
You could script outside of EA and connect to an EA instance. J* (IIRC) is supported meanwhile but I don't know much about that J*-stuff.
As a side note: using path strings is always a secret sauce. Try with a plain name before adding paths and then experiment with slashes/back-slashes.
q.
-
"an error" doesn't really help to narrow it down.
Anyway, you can do almost anything from inside EA that you can do from outside EA.
I use VBscript a lot; see https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/TextFile.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/TextFile.vbs) for a VBScript class that handles reading and writing to textfiles
If you search the repository for TextFile and you'll find a bunch of usages of the class.
It should be rather straightforward to translate the VBScript to JScript
Geert
-
Look into the JScript-CSV in the EaScriptlib. There's a file access for reading (as a start).
q.