Why is this saying that my List have 0 Length?



I am trying to update 3 values in a list continuously using a timer. But it is saying that I have an empty list. I thought I did initialize and put in values.
Also, if I put “add item to list”, it will keep increasing right? how do I prevent that? I just want to replace the values with new ones

Hello,
The block that set LastStateDB to Tiny DB value is the one resetting your value to an empty list

4 Likes

This doesn’t make a lot of sense. You are creating a list and right after that you replace everything in that list with the value of the tag LastState (which by the way is empty, like @bogelin347 told you).

2 Likes

Put the marked block before adding item to list

2 Likes

I see thank you so much!

1 Like

Thank you for the solution! I actually put “get global LastStateDB” at “value if Tag Not There” without moving the blocks you suggested. is that not advisable?

That can cause the same problem if the list was empty and would not change anything if you are variable to itself again.

1 Like


In the end, I did this. Do you foresee any problem with it?

It depends on what you want to do. It’s hard to tell from just looking a a portion of your blocks.
It seems to me like it doesn’t make sense because you ask if the variable LastStateDB is empty:
If yes, then you populate it and save it in TinyDB. That looks ok.
But if no, then you discard what’s in it and replace it for what’s in TinyDB?
I think what you really want to do is find out if the TinyDB tag is empty or not first. Right? The variable (orange blocks) doesn’t link automatically to other components (in your case a TinyDB) so if you ask if the variable is empty, doesn’t tell you if the TinyDB tag is empty and/or exists.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.