Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: PeteC on September 27, 2022, 07:27:34 pm

Title: Detect EA Version in script
Post by: PeteC on September 27, 2022, 07:27:34 pm
Is it possible to detect the version of EA?

I specifically need to avoid using the JScript-Dialog library in 64-bit EA (as it doesn't work). As there is a workaround (but less ideal) using Session.Input, I would like to detect if EA is 32-bit or 64-bit. I can then either use the JScript-Dialog library or create a similar input dialog using Session.Input.
Title: Re: Detect EA Version in script
Post by: Geert Bellekens on September 27, 2022, 07:41:21 pm
The version of EA is easy:
Code: [Select]
Repository.LibraryVersion
The bitness (32 or 64 bit) might be a bit harder. If the version is lower than 16, you are sure it's 32 bit.

Other than that I wouldn't really know. If you find the answer please post it here. I can imagine I'm going to need that one time or another.

Geert
Title: Re: Detect EA Version in script
Post by: PeteC on September 27, 2022, 11:24:44 pm
Making an assumption (that if the ActiveXObject fails it's 64-bit!), this JScript code works:

Code: [Select]
function TestEAVersion()
{
try
{
var vbe = new ActiveXObject("ScriptControl");
// Success = 32-bit? (Assumption)
return 32;
}
catch (err)
{
// Fail = 64-bit? (Assumption)
return 64;
}
}

For me, it provides the expected result for EA15, EA16 32-bit and EA16 64-bit. Obviously the assumption might be wrong and it fails for some reason on a 32-bit system and would then offer the answer as 64.