Start a new topic

AND / OR, If statements

Hi, How can I compare more than two statements with "OR" or with "AND" and how is the syntax to the nextion editor?
For example, my code is:

" if(Kilometers.Valves.txt>"5000") || (Kilometers.Oil.txt>"2000")

{

  Check.pic=25

}else

{

  Check.pic=27

}  "

and I get this error: " Error: Invalid Variables:if(Kilometers.Valves.txt>"5000") || (Kilometers.Oil.txt>"2000")( Double click to jump to code) "

I also try this code: "

" if(Kilometers.Valves.txt>"5000" || Kilometers.Oil.txt>"2000")

{

  Check.pic=25

}else

{

  Check.pic=27

}  "

and the error was the same.

Thanks.


 you can't compare a STRING with ">" or "<" ... that's a NUMBER comparison operator ...


if your "value" is inside a text variable, you first must convert it to a number variable ...

I have convert it to number variable, the code now is:
"if((Kilometers.Valves1.val> 5000) || (Kilometers.Chain1.val> 500))

{

  Check.pic=25

}else

{

  Check.pic=27

}

and the error is the same...:

"Error: Invalid Variables:(Kilometers.Valves1.val( Double click to jump to code) "

Login or Signup to post a comment