Book a Demo

Author Topic: VBScript Global Session object retrieved from elsewhere?  (Read 10000 times)

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
VBScript Global Session object retrieved from elsewhere?
« on: August 03, 2023, 10:20:56 am »
I'm working with Geert's EA-Matic and when those scripts are run in an Addin environment the Session object is not in the global scope.

See https://sparxsystems.com/enterprise_architect_user_guide/16.0/add-ins___scripting/session_object.html

But I can't find anything in the Enterprise Architect Object Model
Reference (https://sparxsystems.com/enterprise_architect_user_guide/16.0/add-ins___scripting/reference.html) that will return me a Session object so I can place it into the Addin scope.

Does anyone know how I retrieve Session from another Object Model reference?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #1 on: August 03, 2023, 06:13:12 pm »
Not sure what you are doing. But when you run a script externally you need to ask Mickeysoft to return an OLE which can be a running session or it can create one (to start EA). Depends on the language you are using which library operation is offered here.

q.

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #2 on: August 03, 2023, 07:06:56 pm »
Geert's EA-Matic is running as an Addin. So everything that is VBScript within EA-Matic is loaded into the EA-Matic Addin's process space to run.

When EA runs a script, it looks like it adds Session as a global object.

But I can find nothing in the Enterprise Architect Object Model Reference for Session, and thus can find no way to add Session as a global object for EA-Matic.

As a workaround I'm transmogrifying Session.Output to Repository.WriteOuput, once I pass through RegEx hell to cope with VBScript line concatentation and optional parenthesis usage for one arg subroutines...

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #3 on: August 03, 2023, 10:39:36 pm »
There seems to be a Session object in EA's J-stuff. However, I can't help with VB since I rather chop me another finger than writing that...

Maybe Geert will catch up when he's back from his (longer) holidays.

q.

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #4 on: August 03, 2023, 11:10:03 pm »
Thanks for looking.

I've got my workaround working.

EA's J-stuff is the same as EA's VB-stuff, which EA automatically adds the global Session into scope for you.

But what I need the Session for is EA's addin-stuff, because I need to inject it into the VBScript engine that is running inside EA addins and not in EA directly.
« Last Edit: August 03, 2023, 11:11:56 pm by Barrie Treloar »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13505
  • Karma: +572/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #5 on: August 22, 2023, 06:22:20 pm »
Hi Barrie,

You ended up in the same dead-end as I did back then when I wrote EA-Matic.

I searched, but haven't found a way to get hold of the Session object.
So unfortunately EA-Matic scripts can't use the Session object.

To be honest, I haven't really missed it. I only ever use the Session object when debugging scripts, never in production.
Is there any specific reason you need the Session object?

Geert

Barrie Treloar

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #6 on: August 22, 2023, 08:54:19 pm »
Was for logging.

But can do that via Repository, and I've sent a pull request with the transmogrification of EA-Matic scripts for Session.ouput -> Repository equivalent.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13505
  • Karma: +572/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: VBScript Global Session object retrieved from elsewhere?
« Reply #7 on: August 22, 2023, 09:12:31 pm »
Was for logging.

But can do that via Repository, and I've sent a pull request with the transmogrification of EA-Matic scripts for Session.ouput -> Repository equivalent.
Thanks, I'm a bit behind on the pull requests, but they are appreciated :)

Geert