Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Hurra on February 08, 2023, 08:23:13 pm

Title: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 08, 2023, 08:23:13 pm
Hello!

I have some scripts I made for Excel export of ModelViews which I use reguarly in an MS Access environment. I 're-created' this script to use on another project, which we at the moment use a local QEAX-file.

When I run the script I get 'Internal Application Error' on the line:

Code: [Select]
function getChildPackages(Package_GUID, packagesArray)
{
var startPackage as EA.Package;
startpackage = Repository.GetPackageByGuid(Package_GUID); // -> this line is referred to in the error message
--- other stuff ---
}

For context, this script replaces the macro #Branch=<GUID># in the ModelViews SQL to a list with all child packages.

I tried to manually enter (hard-code) the relevant Package_GUID in the .GetPackageByGuid() method, but ended up with an infinite loop and out of memory error...

What's going on? I don't even know how to start to troubleshoot and fix this...

Thanks for any input or suggestions!

edit: MS Access environment is v15.2, QEAX is v16
Title: Re: Internal Application Error with script on local QEAX-file
Post by: qwerty on February 08, 2023, 08:35:42 pm
Always a good idea to print the GUID before sending it to EA. You never know. If it looks legit, try an integrity check of the repo. If that's ok too contact Sparx support.

q.
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 08, 2023, 09:03:36 pm
Always a good idea to print the GUID before sending it to EA. You never know. If it looks legit, try an integrity check of the repo. If that's ok too contact Sparx support.

q.

Smart.

Yeah, it seems like the regex doesn't work as expected anymore. Seems strange, but will try to fix it.

My gut says the regex shouldn't be affected by a new environment..?
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Geert Bellekens on February 08, 2023, 09:22:31 pm
There is a better (and faster) way to get the packageIDString to replace #Branch#:

See function getPackageTreeIDString() in https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs)

It does not involve regex, nor does it iterate over package.Packages

Geert
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 08, 2023, 09:40:11 pm
There is a better (and faster) way to get the packageIDString to replace #Branch#:

See function getPackageTreeIDString() in https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/Util.vbs)

It does not involve regex, nor does it iterate over package.Packages

Geert

Thank you.

But since the SQL query is on the ModelView, I get the query from the tagged value notes 'ViewProperties' as a string and need to clean the string and replace #Branch='{GUID}'# with correct GUID-list.

I don't see how I can do that without regex..?

Example:
SQL Query on ModelView:
Code: [Select]
SELECT o.Name
FROM t_object o
WHERE o.Package_ID IN (#Branch='{026F2261-BCA1-4d77-B6F0-204F9E5C0B22}'#)

tagged value notes for 'ViewProperties':
Code: [Select]
<modelview>
<source customSQL="SELECT o.Name&#xA;FROM t_object o&#xA;WHERE o.Package_ID IN (#Branch='{026F2261-BCA1-4d77-B6F0-204F9E5C0B22}'#)"/>
</modelview>

I clean this with some .replace(), and find the (#Branch='{026F2261-BCA1-4d77-B6F0-204F9E5C0B22}'#) with regex, and also the {026F2261-BCA1-4d77-B6F0-204F9E5C0B22} which I use as input to the getAllChildPackages() function. Then I replace again.

Of course I can improve my getAllChildPackages() function as you said, but to get there I don't see not using regex.

Is there a simpler/better way to do this?
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Geert Bellekens on February 08, 2023, 10:00:14 pm
I didn't get fact that you were doing it to update a modelview item.
If you already know the exact string you need to replace, you might not even need a regex to do the replace.

But regardless, the regex is probably not where the problem is; my gut says the same as yours.

Geert
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 08, 2023, 10:05:14 pm
I didn't get fact that you were doing it to update a modelview item.
If you already know the exact string you need to replace, you might not even need a regex to do the replace.

But regardless, the regex is probably not where the problem is; my gut says the same as yours.

Geert

Well it's solved now.

I had to play around with the regex. Seems strange, but all other parts of the other scripts works. Just tweaked the regex..

Thanks for all of your inputs!
Title: Re: Internal Application Error with script on local QEAX-file
Post by: qwerty on February 09, 2023, 05:51:19 am
In case you were not aware: https://regex101.com (https://regex101.com)

q.
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 20, 2023, 08:13:16 pm
In case you were not aware: https://regex101.com (https://regex101.com)

q.

Thanks, I usually use https://regexr.com/

Just seems really strange that the regex worked in one environment, and not another...
Title: Re: Internal Application Error with script on local QEAX-file
Post by: qwerty on February 20, 2023, 08:53:20 pm
Well, regex is even different in different languages (though only in tiny places but if you miss them they don't work). I once happend to have a look at the C source of regex. What a nightmare!

q.
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Geert Bellekens on February 20, 2023, 09:27:45 pm
Indeed, but the regex implementation depends on the scripting engine, not on the database you are using.

There will not be a difference when executing a regex on a .eap model vs a .qea model.

Geert
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Hurra on February 20, 2023, 09:30:56 pm
Indeed, but the regex implementation depends on the scripting engine, not on the database you are using.

There will not be a difference when executing a regex on a .eap model vs a .qea model.

Geert

Well, the only thing I changed in the script was the regex.. Perhaps the text in the tagged value on the 'ModelView' -> 'ViewProperties' is different hence the need to change regex.. I have no idea 🤣
Title: Re: Internal Application Error with script on local QEAX-file
Post by: Geert Bellekens on February 20, 2023, 10:06:46 pm
Perhaps the text in the tagged value on the 'ModelView' -> 'ViewProperties' is different hence the need to change regex.. I have no idea 🤣
That could be it.

Geert