Start a new topic
Solved

&& operator fail in last IDE

Hello,


After a long month, i'm trying to change some part the Nextion 7" touch LCD display.

I've installed the last update but IDE con't compile and stop at this line :

 

 

if(p0.pic==18&&p1.pic==18&&p2.pic==18&&p3.pic==18&&p4.pic==18&&p5.pic==18&&p6.pic==18&&p8.pic==18&&p9.pic==18&&p10.pic==18&&p12.pic==18&&p13.pic==18)

 But it's work perfectly on the LCD compiled with an old IDE.

The full code :

 

if(p0.pic==18&&p1.pic==18&&p2.pic==18&&p3.pic==18&&p4.pic==18&&p5.pic==18&&p6.pic==18&&p8.pic==18&&p9.pic==18&&p10.pic==18&&p12.pic==18&&p13.pic==18)
{
  t5.bco=0
  t5.pco=0
  ref t5
  pacc.p0.pic=18
}

 From "if" to ")" it's a single line.


Have you an idea ?

Thanks


Le réparateur de PC

 



in general, such a "construct" is less optimal and should be avoided ...

    - in such a construct, to get a true or false condition all conditions must be tested ...
    - when using nested if statements instead, the next if is only executed and checked when the current is true ...


 

re,


OK but why the IDE can't compile ? It's not an error but a bad practice ?


Have you an exemple code to solve it ?


Thanks


Le réparateur de PC

 

sys0=p0.pic+p1.pic+p2.pic+p3.pic+p4.pic+p5.pic+p6.pic+p7.pic+p8.pic+p9.pic+p10.pic+p11.pic+p12.pic+p13.pic
if(sys0==252)
{
  t5.bco=0
  t5.pco=0
  ref t5
  pacc.p0.pic=18
}

 

 


1 person likes this

re,


PFFFF why i've never think to this ????


Thanks !!!!!


Le réparateur de PC

I don't know ... ;-)

which version did this code ever work?

For the record:

In versions 0.33 and later of the Nextion Editor

   Compile traps the invalid complex evaluation and displays error.

In version 0.32 of the Nextion Editor

   The Compile process did not trap the invalid complex evaluation.

   but rather relied on the user to follow the instruction set and not

   use invalid statements in the user Event code.


The use of && has never been supported, only that v0.32 never tested

user statements to determine their validity, such invalid statement

would soon be known to be invalid when failure in Debug and Device

would not render the intended results.


if(p0.pic==18&&p1.pic==18)

Such an evaluation condition would short circuit only evaluating until

the first occurrence of 18  (p0.pic==18), result would be based on this

and this alone with the remaining discarded, ignored, unevaluated.


As such, this never worked, not even perfectly.


For Historical purposes, the if statement from v0.32

Example:

if(t0.txt=="123")

{

  t1.txt="password is correct"

}

if(t0.txt!="123")

{

  t1.txt="password error"

}

Notes:

   The two braces must be on a separate line,

   Does not support nested if

   Does not support else

   Value type variable support

  1. Greater than (>)
  2. Less than (<)
  3. Equal to (==)
  4. Not Equal (!=)
  5. Greater than or Equal to (>=)
  6. Less than or Equal to (<=)
   String type only supports
  1. Equal to (==)
  2. Not Equal (!=)
   Must have strict beginning and ending parenthesis
   Does not support multiple parenthesis
   Only two variables directly evaluated
      - does not support calculation before evaluation
      - if(j0.val+1>0) This is not supported.
   If statement can only be written in user Event code
      - can not be transmitted over serial.
Login or Signup to post a comment