Author Topic: Writing to text file from JScript in EA  (Read 3352 times)

MrSnow

  • EA User
  • **
  • Posts: 20
  • Karma: +1/-0
    • View Profile
Writing to text file from JScript in EA
« 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!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Writing to text file from JScript in EA
« Reply #1 on: March 01, 2019, 09:01:30 pm »
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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13274
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Writing to text file from JScript in EA
« Reply #2 on: March 02, 2019, 05:27:42 am »
"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 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Writing to text file from JScript in EA
« Reply #3 on: March 02, 2019, 05:44:37 am »
Look into the JScript-CSV in the EaScriptlib. There's a file access for reading (as a start).

q.