0

I'm trying to validate user entered values as being within a range that is equal to a prior user entered number plus/minus constant numbers but the script seems to only recognize the lower bound of the range and the upper bound is always the prior user entered number plus any value less than one (aka user entered 55 so 55.999999 works but 56 turns red). Code:

if (BUNO.rawValue>=164865){ 
    if (Auto1Right.rawValue>=45 && Auto1Right.rawValue<=75)
    {
        var eleven = 11.00;
        var auto2min=Auto1Right.rawValue-eleven;
        var five = 5.70; 
        var auto2max=Auto1Right.rawValue+five;
        if (this.rawValue>=auto2min&&Man2Right.rawValue<=auto2max)
        {
            Man2Right.fillColor="0,255,0";
        }


    }
    else
    {
        Man2Right.fillColor="255,0,0";
    }

}

3 Answers3

0

I think you might just have a small typo. You have two equal signs here

var auto2max==Auto1Right.rawValue+five;

It should probably look like this:

var auto2max = Auto1Right.rawValue + five;
Tjofras
  • 2,116
  • 12
  • 13
  • ah sorry, that second = sign got added when i was editing in the submission box, it's not actually there in my code, i'll edit the original post. – user2196209 Aug 13 '13 at 20:41
  • apparently this can be avoided by changing the "+" symbol to a "-" symbol and changing your variable value to a negative number. i have no idea why it won't use the "+" for addition without changing the variable to a string instead of a number but it works. thanks for the help! – user2196209 Aug 13 '13 at 21:57
0

apparently this can be avoided by changing the "+" symbol to a "-" symbol and changing your variable value to a negative number.

i have no idea why it won't use the "+" for addition without changing the variable to a string. According to everything i can find the "+" symbol should add both numbers and strings.

0

It sounds like the rawValue is being interpreted as a string, not a number. Have you tried casting your variables?

if ( parseFloat(BUNO.rawValue) >= 164865 ){
    var a1r = parseFloat(Auto1Right.rawValue)
    if (a1r>=45 && a1r<=75)
    {
        var eleven = 11.00;
        var auto2min=Auto1Right.rawValue-eleven;
        var five = 5.70; 
        var auto2max = a1r + five;

        var thisRV = parseFloat(this.rawValue) ;
        var m2RV = parseFloat(Man2Right.rawValue) ;
        if (thisRV>=auto2min && m2RV<=auto2max)
        {
            Man2Right.fillColor="0,255,0";
        }


    }
    else
    {
        Man2Right.fillColor="255,0,0";
    }

}
Ben
  • 571
  • 2
  • 4
  • 15