Book a Demo

Author Topic: print/println in Javascript  (Read 11567 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
print/println in Javascript
« on: September 05, 2021, 07:37:52 pm »
does not work for me.
e.g. there is a simple example in Local Scripts: JavaScritp1, that also does not work on my computer: Win10+EA15.2:1559

Do you got any idea to make print for Javascript scripting work?
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: print/println in Javascript
« Reply #1 on: September 05, 2021, 08:40:22 pm »
Use the repository operation to write to the System log window.

q.

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: print/println in Javascript
« Reply #2 on: September 06, 2021, 04:03:32 pm »
ok, qwerty - where do I find the documentation about the Repository functions? I looked in some User Guides, e.g. Automation, Object Model, Scripting - and could not identify it.
Rolf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: print/println in Javascript
« Reply #3 on: September 06, 2021, 04:12:26 pm »
When doing scripting you can either use Session.Output or WriteOutput (string Name, string Output, long ID)

See https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/automation/repository3.html for documentation.

Geert

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: print/println in Javascript
« Reply #4 on: September 06, 2021, 05:24:10 pm »
Thank you Geert - now I found WriteOutput also in the automation.pdf. Nice that one can create a dedicated tab. I found the doc of Session.Output here and in automation.pdf.

It is kind of confusing when officially delivered examples - like JavaScript1 - do not work. Thinking about bad local installation or environment, prior to lack in quality of delivery cost time and productivity. Not delivering those examples would be better, instead.
« Last Edit: September 06, 2021, 05:25:42 pm by ngong »
Rolf

timoc

  • EA User
  • **
  • Posts: 201
  • Karma: +14/-0
    • View Profile
Re: print/println in Javascript
« Reply #5 on: September 21, 2021, 06:26:37 pm »
I have found it is easier to create a compatibility include file which defines a print and println functions in terms of EA.

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: print/println in Javascript
« Reply #6 on: September 21, 2021, 10:29:12 pm »
Probably a stupid question but I have tried Repository.WriteOutput, and nothing is output at all. Does the Tab within the System Output window referred to in the first parameter have to be created first? If so how?

Phil
Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: print/println in Javascript
« Reply #7 on: September 21, 2021, 11:46:58 pm »
Yes, like this:
Code: [Select]
const outputName = "My Tab name"

'create output tab
Repository.CreateOutputTab outPutName
Repository.ClearOutput outPutName
Repository.EnsureOutputVisible outPutName
'inform user
Repository.WriteOutput outPutName, now() & " My Message", 0

Geert

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: print/println in Javascript
« Reply #8 on: September 22, 2021, 12:13:32 am »
Perfect thanks Geert

Phil
Models are great!
Correct models are even greater!