Variable not saving properly

Hey !

So let me explain :

I have these blocks

image

Which leads to the execution of these blocks

image

And these are working fine. But, when I try to use the same variable in another procedure that has no links with these (Launches when a button is clicked), it doesn’t work…Here are the blocks :

The button image executing image

The index variable is not working here, the name one is working fine strangely

Any ideas on what is going wrong ? Thank you !

Anyone ? This is really disturbing, it never happened to me

Here a picture describing better : The ones in red are the ones in which the variables are showing undefined and the ones in green where the variables work fine :

Hey @Mark ! Any idea on that one ? Maybe it’s a bug when you get out of the function the variable returns to nothing or I don’t know :confused:

Thanks !

You can’t modify the list viewer’s text items directly using the list remove block.

What you need to is create a variable, set the list to that variable, modify the list, and then set the list items to be what’s in the list.

Example project
https://x.thunkable.com/copy/8048f4b3458eb997d994678d924bbfb7

Thanks for the trick but the problem is still that the variables aren’t saving the values out of the green blocks :confused:

Also I didn’t understand what you were referring to. Are you saying that I can’t remove an item from the list by directly inserting the listviewer into the in list … block ? Because it works perfectly for me :slight_smile:

Oh, you are correct - you can use the green blocks that way…that’s scary but true.

To the first question, the problem is that you are naming the variable “index” when the green block is already called index. These values clash with each other, meaning you can’t update the global variable “index” inside the ItemClick event.

Basically your orange variable blocks (index, name) and the green variable blocks (item, index, etc) should NEVER have the same names. Eventually we’ll change the system so this problem is more obvious.

1 Like

The first thing that I would do is to have different names for the global variables that you use and the argument names for your procedures. Using the same name (e.g. 'index') is just asking for trouble. For example, in your 'check' procedure you increment the value of 'index'. Which version of 'index' do you mean? The one that is local to the 'check' procedure or the global 'index' variable that is accessible to all your blocks? Changing those names might itself fix your problem, but if not it will make it much easier to diagnose what is going wrong.

-Mark

1 Like

Ok so basically if I open a procedure with whatever = index
whatever1 = count

It doesn’t change anything ? Didn’t understand it this way :confused: Thanks !

I’m sorry, I don’t know what you mean by the above.

-Mark

I’m saying that the way you name the arguments of the procedure is not linked to the name of your variables right ? I’m pretty stupid I didn’t get that in the first time :confused: I’m downloading the app at the moment, will keep you updated.

Thanks

Thanks @Mark and @paulmw, my issue is fixed, but two more are left.

This one on getting a list from localstorage : Saving & Getting an information after the app was closed

And another one is about the next screenshot, these blocks are supposed to replace the item at the #position but it just doesn’t change it, it adds a new one :confused:

Also, the edit variable only is set to 2 the first time the list is clicked, after that it never works.

Thanks for helping

https://streamable.com/coe7i