How to set the bco?

I’m creating a code where pressing a certain button will cause the background color of all pages change. There’s three such buttons in total. I tried two methods to do this, first, I tried,
page0.bco=0
page1.bco=0
page2.bco=0
page3.bco=0
page4.bco=0
page5.bco=0
page6.bco=0
and in return, it gave me:
Total size of font:40,287
Page:page0 Memory Occupied:16+132=148
Page:page1 Memory Occupied:16+120=136
Page:page2 Memory Occupied:16+96=112
Page:page3 Memory Occupied:16+572=588
Page:page4 Memory Occupied:16+372=388
Page:page5 Memory Occupied:16+320=336
Page:page6 Memory Occupied:16+132=148
Error:Invalid Variables:page0.bco( Double click to jump to code)
Error:Invalid Variables:page1.bco( Double click to jump to code)
Error:Invalid Variables:page2.bco( Double click to jump to code)
Error:Invalid Variables:page3.bco( Double click to jump to code)
Error:Invalid Variables:page4.bco( Double click to jump to code)
Error:Invalid Variables:page5.bco( Double click to jump to code)
Error:Compile failed! 8 Errors, 0 Warnings,

Something notable here is that, it didn’t show any error for page6 which is the page I had the buttons in. So, I did some research and aparently, to use the command globally, I only needed the command “bco=0”
so, I tried that with the other two buttons. and the output was,

Available Memory:3584
Global Memory:16
Total size of picture:10,392
Total size of font:40,287
Page:page0 Memory Occupied:16+132=148
Page:page1 Memory Occupied:16+120=136
Page:page2 Memory Occupied:16+96=112
Page:page3 Memory Occupied:16+572=588
Page:page4 Memory Occupied:16+372=388
Page:page5 Memory Occupied:16+320=336
Page:page6 Memory Occupied:16+132=148
Error:Invalid Variables:page0.bco( Double click to jump to code)
Error:Invalid Variables:page1.bco( Double click to jump to code)
Error:Invalid Variables:page2.bco( Double click to jump to code)
Error:Invalid Variables:page3.bco( Double click to jump to code)
Error:Invalid Variables:page4.bco( Double click to jump to code)
Error:Invalid Variables:page5.bco( Double click to jump to code)
Error:Invalid Variables:bco( Double click to jump to code)
Error:Invalid Variables:bco( Double click to jump to code)
Error:Compile failed! 8 Errors, 0 Warnings,

How can I fix the code?

N/B: I’m only starting out with Nextion so, I don’t have much knowledge about the editor, display or the nextion script. Any help would be appreciated. Thank you for your help and sorry for the inconvenience.

Most likely bco is not global on each of the pages. I would make one global variable to hold the state of all of the page bco’s. In each page’s PreIinitialize Event, set the bco for that page.

Hi! Thanks for replying. Your idea is a great method indeed but I was hoping to make all the pages change with a single button instead of having to add extra code on every page. As this project has a lot of pages and I was hoping to minimize the memory usage. So, I’m not sure if it’s the best method to use for this project. But starting out without a mentor, I really appreciate your help. Also, about bco not being global, I had read about it online on an unofficial page, so I could be wrong. I’m not very experienced with Nextion but I like your way of thinking, can you tell me a bit more about how you came up with that hypothesis and what other alternative options we have?

Once again, Thank you so much for your help and sorry for all the inconveniences. Thank you.

It’s not a hypothesis. The only way to directly set a value on a page that isn’t active is that value must be global. Global memory is limited, so using it should be done carefully.

Make the page0.bco global (or add a global variable). In the Preinitialize Event on each page add this: bco=page0.bco (use the actual page name). Copy this to each page. In your button add this: bco=??? and page0.bco=bco. Copy the button to each page.

I see. Thank you so much. Have a great day.