Book a Demo

Author Topic: Run the last script, dynamic include?  (Read 9556 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Run the last script, dynamic include?
« on: May 04, 2018, 11:34:06 pm »
Hi,

I'm trying to find a way to run a script that will itself call the last script used.
Let's say that in the Package scripts, you have
- RunLast
- ScriptA
- ScriptB

If I run ScriptA, it will store this ref somewhere in EA.
Calling RunLast will retrieve the ref and run ScriptA...

The following does not seem to be feasible:
- have a dynamic include (!INC) on the script found from the ref
- call this script main function (e.g. OnProjectBrowserScript) when the group and script names are set as variables e.g. groupName.scriptName OnProjectBrowserScript

Do you know if there is a solution to achieve that?

Note: I thought of an option that would involve the following:
- rename each script's main function e.g. OnProjectBrowserScriptA, OnProjectBrowserScriptB, OnProjectBrowserScriptC
- include all scripts in the RunLast Script : !INC GroupA.ScriptA, : !INC GroupA.ScriptB, etc
- add a switch case in RunLast script that will call the function matching the ref e.g. ScriptA -> call OnProjectBrowserScriptA
-> unfortunately this doesn't work either since all my scripts have an option explicit which generates an error



Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Run the last script, dynamic include?
« Reply #1 on: May 07, 2018, 08:57:37 am »
First thoughts... Use an intermediate include script that you write the appropriate include to. (In the form !INC My.script)

Unfortunately, I think the script will be cached so that won't work. It also wouldn't be a good solution in a multi-user repository.

Next best solution, using Geert's? addin that can run scripts (or similar) to do it. A variation of that would be to create an ActiveX object that can be created from your scripts to assign or run the latest scripts.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Run the last script, dynamic include?
« Reply #2 on: May 07, 2018, 04:30:04 pm »
Hi Simon,

Thank you for your feedback.
In the current scenario, we use scripts as users don't have the admin rights to install additional software on their PC.

I looks like the best option would be to treat it as a new EA feature to improve the user experience.

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Run the last script, dynamic include?
« Reply #3 on: May 07, 2018, 06:57:16 pm »
Hi,

You can write and deploy EA Add-Ins installable without Admin Rights. You find a template at:

https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoAddinTemplate

Best regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Run the last script, dynamic include?
« Reply #4 on: May 08, 2018, 12:50:09 am »
Hi Helmut,

You're right and I have implemented a feature for a client with eaUtils which is available in a Portable Install edition (thanks to your info via this forum).
So I have a workaround if I add this "run last script" in eaUtils, however I think it would be nice to have it natively in EA.

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Run the last script, dynamic include?
« Reply #5 on: May 10, 2018, 07:39:21 pm »
Actually,

This could work if you treated your whole set of scripts as a library.
Write only function/subs, but in none of them actually call it.

Then make sure that you include all scripts using !INC
(internally these all get stitched together in single giant script)

Then you remember which script was run last and re-execute that.

It would be a lot of work, and I'm not sure of the benefit of it all, but it is doable.

Geert

PS. If you need "regular executable scripts" as well then you can create a second set that does nothing more then execute the sub/function in your script library.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Run the last script, dynamic include?
« Reply #6 on: May 16, 2018, 01:08:11 am »
Hi,

I found an easier option (in my opinion) by calling a function at the beginning of each script that copies its content/code to a dedicated "Run Last" script (with separate versions for the Project Browser and Diagram).

It works yet I can't find a way round an annoying issue: the screen tree list must be refreshed by the user (or the project closed/opened) so the updates are taken into account (see my related post here: http://www.sparxsystems.com/forums/smf/index.php/topic,39778.0.html).

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com