A problem with list and tinydb

hello i am currently working on a code and i have a problem with my list
i have created a list with tiny dB that can save numbers and sum them and show them on labels but when i try save the progress it saves and when i want to show them it just pop up 5050 idk why
from hamada to duolingo.aia (5.0 MB)
its located in fitness screen its not in English but if u need anything to translate just ask me and button 7 is the button that show the progress

image
button 1 is for start
button 2 is for stope
button 3 is for rest
thanks

Hello,
It gives you 5050 because you are adding (when you click on button7) the numbers from 1 to 100:

what do you want to do in the "for" loop?

1 Like

i don't want loop i just want to save progress

You have a loop to add numbers from 1 to 100 to the "global list", What do you want to do there? where is the progress?

and why this is exactly the same than here:

are you the same person?

no I'm not that my friend we all are having an exam so he shared the code with me but the code didn't work with me like it worked with him

I guess the code is not working neither for him....anyway, do you understand what are you doing in that Initialize block? what do you want to achieve and how those blocks work?

no :grinning:

then? Do you want someone take your exam for you?

1 Like

its not like that but we have learned mit app inventor only from you tube for only 3 days a lot of us have no idea what to do that why we came here

Initialize block is executed when the screen starts.

First thing you are doing is to read from tinyDB the value stored under the tag "calories" and storing the value in the global variable "progress_list":

Then you are displaying the content of "progress_list" (which is expected to be list) in a listViewer (twice ?? you can remove one):

and here comes the strange thing... you are creating a new list ("global list"), with the number from 1 to 100 and storing it under the tag "calories" (overwriting the information you had stored in tinyDB):

So, what you have at this point in tinyDB, in the "calories" tag is a list of numbers from 1 to 100. Do you need this part of the code for anything? Has it sense for you?

yeah i think this get the value from label 4 and store it in the list

Well,, but that will not happen in Initialize block, because in that block, you are "starting" the screen and, anyway, there you are storing the numbers from 1 to 100....try to remove that last part of the code with no sense and, when button4.Click, you are adding the label4.text value to the list...then try to store there the list in tinyDB.

like this?

Try with this:

In Initilize block only initilize the variable "progress_list" with the stored value in tinyDB and show it in ListView.

Then, in button4, when you are adding label4 to list, store the list with that new value to tinyDB.

image

what do you want to do in that button? Think in what do you need there to achieve what you want to do. Where is the data you want to add?

i want this button to change the labels to show the value after summing up

what do you want to add? where is that information?

its on label 4 the calories burned when i click on button 7 it saves label 4 to the list

and do you want to add all the elements stored in the list?