Start a new topic

Change variables on another page


Hello everyone, I have a very simple problem, but it's driving me crazy. I have a button on page 0 that as soon as I press it, it sends the following command: "page1.n0.val = 100" On page 1, I have a numeric label called n0, and I want to get the value I set on the page 0 button, but when debugging, an error appears in the code "page1.n0.val = 100"The photo with the error is attached for you to see.I hope you help me with this little question. I'm sure it's some syntax error, but I did not find any information to correct it.


image



Lose the spaces


showing page0 does little to show page1 where n0 supposedly resides



But, I want to press the button on page 0 and label n0 on page 1 receive the value I set in the button on page 0. Could you understand? It got a little confusing kkkk


image



image


scope - wrong scope.


Patrick, now that I understand, I've already been able to change the scope to global rather than local. Sorry for the inconvenience and thanks for the help.

image


On new Forum, (register, set password, login to view)

Nextion order of Events
1. Loading Page Preinitialize Event runs
2. Existing Page is dumped to make room for Loading Page
3. Loading Page is loaded exactly per HMI design
4. Global values are restored from Nextion memory
5. Loading Page Postinitialize Event runs
6. Nextion then enters loop waiting for one of
  • Incoming Nextion command over RX
  • Touch triggered from Touch sensor
  • GPIO falling/rising edge from bound IO
  • Timer Component .tim expires
  • Touch/Serial timer for Sleep expires

So page 1 does not exist in 3584 bytes of HMI memory
   when page 0 assigns to page1.n0

This is about Variable Scope
  - local only exists locally (on page)
  - global exists globally on all pages.

When you want page1.n0 to exist globally
 - then you must set it to be of global scope.

1 person likes this

Thank you very much and have a great day.

Happy Coding


Don't forget to Register on the New Forum


Login or Signup to post a comment