Start a new topic
Implemented

simplify programming/functions/instructions

Hi,

I just bought a Nextion enhanced to play with it, but i have trouble to properly add a IF function.

The IF function is straightforward ( IF X = 1, do Y, otherwise Z) but to implement them in to Nextion is a bit "how your doing" for a newbie. Not mention the description on the errors. "click here the jump to code" is not very helpful to fix the error, only pointing to one. I would be VERY helpful it its showing a few solution to fix the error.
"Invalid Variable" is a way to common description which means to many things it seems. (missing b0 for example)

for example:
I relay only on 3 examples on how to use the IF function used in Nextion Editor.
If i copy/paste the examples they are NOT working in the first place (I've added the required test/button/page if needed).

For example (Nextion wiki):
Example 3: Below codes can switch content of txt of button component b0 among 1, 2, 3 in press event)

if(b0.txt==”1”
{    
  b0.txt==”2”  
} else if (b0.txt==”2” )
{ 
  b0.txt==”3”  
}else
{ 
  b0.txt==”1”
}

output:
Error: SYNTAX ERROR: "if" statement must end with ")":if(b0.txt==”1”( Double click to jump to code)
Error: Compile failed! 1 Errors, 0 Warnings,
* Ok, i get this, adding a ")" at the end.
if(b0.txt==”1” ---->  if(b0.txt==”1”)

More errors!! :)
output:
Error: Invalid Variables:if(b0.txt==”1”)( Double click to jump to code) 
* Adding b0 will remove this error.

Error: Invalid Variables:b0.txt==”2”( Double click to jump to code)
* took me a while to find this one because == is valid so is "2". Why?
b0.txt==”2” ----> b0.txt=”2”

Error: Invalid command:} else if (b0.txt==”2” )( Double click to jump to code)
* a spaces to much on 3 locations, really? (tool me ages to figure this one out)
} else if (b0.txt==”2” ) ----> }else if(b0.txt==”2”)

Error: SYNTAX ERROR: Extra "{":{( Double click to jump to code)
Error: Compile failed! 4 Errors, 0 Warnings,
* this one has something to do with the typo above and will go away.

then:
Error: Invalid Variables:b0.txt==”3”( Double click to jump to code)
Error: Invalid Variables:b0.txt==”1”( Double click to jump to code)
Error: Compile failed! 2 Errors, 0 Warnings,
* same as above remove a =

Next request is to add available Instruction sorted at function by, for example, right clicking the event window or commands partly show up when your typing the instruction. This way you don't have to relay on the wiki pages to look for instructions.


what about using "Visual programming languages" as a option?


Using pictures instead of text and where buttons are sequential,

previous code such as

if(b0.txt=="1")

   {

      b0.txt="2"

   }else

   {

      if(b0.txt=="2")

        {

         b0.txt="3"

      }else

      {

         b0.txt="1"

      }

   }

can be reduced to

  b[3].pco=b[3].pco+1%3+6

code helpers have been included in event coding area

and the debug simulator user instruction input area


Considered implemented

I am now reviewing all of the Feature Requests, this will take some time, patience please.

Visual programming approach, Included Instruction Set with examples, Descriptive errors. Carried forward


Not sure if you solved this, so incase you haven't


if(b0.txt=="1")

{

b0.txt="2"

}else

{

if(b0.txt=="2")

{

b0.txt="3"

}else

{

b0.txt="1"

}

}


Yeah, the editor isn't state of the art visual studio compiler.  But it grows on you.  Very powerful chip on that back of the Nextions creating great potential for your projects.  It's just a matter of getting use to all the little quirks.  Try to remember that little chip is 8K ram and gives you 3584B for your pages, so pretty amazing capabilities being accomplished in so little space.  A think a Visual Studio would probably blow the output limits just attempting a Hello World.



1 person likes this
Login or Signup to post a comment