A problem with list and tinydb

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?

yes

There you have your answer...what do you need then in that empty socket?

A post was merged into an existing topic: How can I save text of textbox with a button click?

This is the sum of list problem , judging from the tag and the loop