Only the first 2 global variables are remembered after restart | Intech Studio
💬 general General

Only the first 2 global variables are remembered after restart

Highvoltage
Highvoltage · · 3 replies

So i'm trying to define global variables for a page, and i presume it's best placed in the "utility" section?
I put in a code block:
sens, velo, ch_tog, test = 1200, 300, 0, 321

Then i made a button to just print out the values to debug.
When i commit the code, everything works.
After restarting the device, i get al sorts of errors, and it turns out, only the first 2 defined variables are recalled. If i edit the code block and commit, all variables work again, UNTIL i press STORE.
Then again all variables get lost after the first two....

Is this a bug, or am i placing my variables in the wrong place?

Replies (3)

Highvoltage Highvoltage ·

I get this error message if i try to use the variables:

image.png
Highvoltage Highvoltage ·

OK, i realized that there is a "SETUP" part, and the "utility" section was the wrong place to store variables.
Now it works!!!

mvdirty mvdirty ·

Yeah, the utility event is what runs when you press the small button on the edge of the module, usually used for paging. You can put various declarations there, but they’ll only take effect after pressing the button or firing the utility event programmatically from code elsewhere.

Discord

View on Discord

This post is from the Intech Studio Discord community.

Open thread →