Fix function problem

i=fix(-10) returns -9 instead of -10.

Good catch! This bug has been there for over a decade. It’s fixed in the next build, but in the meantime, add this to your app:

Javascript
function jsFix(n) {
    //simulate vbScript FIX()
    if (n >= 0) {
        i = Math.floor(n);
    } else {
        i = -(Math.floor(-n))
    }
    return i * 1;
}
End JavaScript

Ah, I think I have encountered that before but I compensated for it, therefor your fix in the next build might actually cause issues in my app.

When you have fixed it can you please proved a code snippet for backward compatibility.

Many thanks

I just created a function named MyFix and used it.

Incidentally, I had a miserable time debugging this as Chrome debugger stopped working correctly. Appears related to error: DevTools failed to load source map. Anyone know how to fix this? (Sorry for hijacking my own thread.)

@Pro_Certs: We will put it in the release note. For future sanity, you’d be better off removing your workaround than having a workaround for a workaround. :slight_smile:

@norm: You can ignore source map messages - it does not cause issues.

The issue is that stepping through the code with the debugger shows the incorrect lines. It is several lines off and can be in the wrong routine. I’ve seen several folk say this is caused by a source map problem. This wasn’t always a problem.

If you’re coding in BASIC, the line numbers won’t always line up with the JavaScript code.

Not all BASIC statements map 1-1 with their JavaScript equivalents. Source maps won’t help with this.

I am not looking at the Basic statements. I am stepping through the JS. If I set a break, it stops but highlights a line several lines above the breakpoint. Stepping through appears to jump into functions before it should. Variables show as undefined until several lines after they have been defined. Very difficult to figure out what is going on. This didn’t use to happen.

I’m writing in JS. I had a similar problem a while back. It had to do with cache and pwa. The debugger had wrong line numbers and incorrect data in memory list, but the console gave correct results.

It is fixed by doing hard refresh. Right click refresh button, last option. PWA can be painful at times.