Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Barrie Treloar on August 03, 2023, 10:20:56 am

Title: VBScript Global Session object retrieved from elsewhere?
Post by: Barrie Treloar 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 (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 (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?
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: qwerty 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.
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: Barrie Treloar 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...
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: qwerty 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.
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: Barrie Treloar 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.
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: Geert Bellekens 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
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: Barrie Treloar 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.
Title: Re: VBScript Global Session object retrieved from elsewhere?
Post by: Geert Bellekens 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