Missing Global Variables?

Hello...

I am trying to create an app for people to log their blood pressure. I currently have 3 screens

  • A Profile screen that asks for name, age, weight, ethnicity, height
  • A View screen - where, once the profile has filled in, people add a datestamped 120/80 like reading

I also have an Admin screen to clear the readings etc... bits and bobs.

I am using TinyDB and have 4 instances ProfileDB, diaryDB, medicationsDB and informationDB
I am currently using a ListView to show the readings but later it could also be a chart.
I store/use the readingsDB in a "readings" global.

My problem is this.. I am trying to store the readings (essentially a list of lists) and to begin with I did this... to set up my data.

All was working fine... I could add items to the list, but when moving things around a bit ... all of a sudden on the viewEntries screen, the variables objects no longer know about my "readings" variable

You can see lots of red crosses on my code.

The problem started after I'd temporarily added the initialise variable code to a function block.... then moved it out again...

Can anyone spot anything awry?

Thanks

Tom

Global variables are only accessible within the screen that holds their init global block.

Ah thanks... and are they init'd if they already exist... Or do you just add the block to say you want to use it?

Add the variable block on each screen that requires it, and load the data for that variable from the tinydb

1 Like

Many people avoid the problem by using stacked Vertical Arrangements instead of screens.
Keep them invisible, only one visible at a time.

1 Like