[HTML/JS] Issue with GetSimVarValue function, returning 0 or 1 with boolean simvars

Version: SU 15 - 1.37.4.0

Frequency: Consistently

Severity: High

Context: In flight, using any aircraft (third-party or default)

Bug description: When retrieving the value of a simvar (this also includes L: vars) with the type boolean [for example: (L:XMLVAR_MyBoolLocalVar, bool) or (A:GPS DRIVES NAV1, bool)] from JavaScript, through the SimVar.GetSimVarValue function, that function returns either 0 or 1, and not true or false, as it used to happen before the SU15 flighting builds.

Repro steps: Below is a screenshot of the Coherent Debugger, showing the issue through the Debugger’s console. You can test not only there, but also from an HTML instrument.

I tested this behavior by sending the following code blocks into the Debugger’s console:

console.log(`SimVar AUTOPILOT AVAILABLE = ${SimVar.GetSimVarValue("AUTOPILOT AVAILABLE", "boolean")}`);
// returned "SimVar AUTOPILOT AVAILABLE = 1"
console.log(`SimVar IS IN VR = ${SimVar.GetSimVarValue("E:IS IN VR", "boolean")}`);
// returned "SimVar IS IN VR = 0"
console.log(`SimVar GPS DRIVES NAV1 = ${SimVar.GetSimVarValue("GPS DRIVES NAV1", "boolean")}`);
// returned "SimVar GPS DRIVES NAV1 = 1"

Then, I tested the following (as seen below):

Here, I tested with my current production build of my EMB-110 Bandeirante, because of the L: var defined in the screenshot, but it is part of the example, as this also happens with local variables. Please pay attention to the following code block, replicating the same code “commands” sent to the Debugger’s console:

let testVar = SimVar.GetSimVarValue("L:XMLVAR_NGSE110_GPSGovernsCDI2", "Boolean");
console.log(testVar);    // Returned 1 (for true) in my reproduction sample
// Now, let's negate that value
testVar = !testVar;
console.log(testVar);     // When retrieving that var again, it returns false
// This means that the JS var declared here is no longer a Number and it became a boolean
// What if I negate it again?
testVar = !testVar;
console.log(testVar);    // It returns true, and not 1 as before.

As I previously said, before this weird issue happened, the function used to correctly return a boolean in JavaScript, but it’s not the case right now. Has something changed internally on that function?

Thank you very much in advance for your answer in this regard.

Regards,
Carlos Gonzalez
NextGen Simulations

Hello @cdgonzalezgo @ScorpionFilm422

Are you able to tell when the issue appeared?
I checked the live version (1.36.2.0) and I have a similar behavior.

Regards,
Sylvain

I’ve never seen a true/false returned in this function. It has always been 1/0.

I can’t say.
I was in debug session and got an issue. I saw the simvar problem and thought it was the origin of the issue but in fact, it was not. So probably it exists from a long time.

That’s my feeling as well.
As far as I can tell, this call has always gone through Simvars.getValueReg which returns a number.

Regards,
Sylvain

Hi Sylvain (@FlyingRaccoon),

Not sure, honestly. Back in May 2023, when I was debugging one of the HTML instruments for my EMB-110, the boolean SimVars used to return me true or false when checking against the Coherent’s debugger, but I am not sure at all when this happened.

Thanks God the sim can handle those values correctly, because I checked in my development environment and the aircraft’s digital instruments work correctly, especially the HSI’s DME display, but it was a matter of curiosity, because I used to get the boolean simvars as true or false when I passed the function through the Coherent’s console.

Regards,
Carlos Gonzalez
NextGen Simulations

This has always been the case. Changing the behaviour would probably break some things.