Author Topic: Internal Application Error with script on local QEAX-file  (Read 3498 times)

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Internal Application Error with script on local QEAX-file
« 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
« Last Edit: February 08, 2023, 08:25:58 pm by Hurra »
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Internal Application Error with script on local QEAX-file
« Reply #1 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.

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Internal Application Error with script on local QEAX-file
« Reply #2 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..?
always learning!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Application Error with script on local QEAX-file
« Reply #3 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

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

Geert

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Internal Application Error with script on local QEAX-file
« Reply #4 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

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?
always learning!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Application Error with script on local QEAX-file
« Reply #5 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

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Internal Application Error with script on local QEAX-file
« Reply #6 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!
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Internal Application Error with script on local QEAX-file
« Reply #7 on: February 09, 2023, 05:51:19 am »
In case you were not aware: https://regex101.com

q.

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Internal Application Error with script on local QEAX-file
« Reply #8 on: February 20, 2023, 08:13:16 pm »
In case you were not aware: 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...
always learning!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Internal Application Error with script on local QEAX-file
« Reply #9 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Application Error with script on local QEAX-file
« Reply #10 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

Hurra

  • EA User
  • **
  • Posts: 183
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Internal Application Error with script on local QEAX-file
« Reply #11 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 🤣
always learning!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Application Error with script on local QEAX-file
« Reply #12 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