Simple variable interation

I’m not sure exactly what I’m missing here, but it has to be something pretty basic.
I initialize an app variable = 0
I have a button that executes a function.
The function sets a label to the variable and then speaks the variable.
It then changes the app variable by 1.
Updates the label and speaks the new value.
But the values do not change from the initialized value.

Separate question. Is there a code watch window so we can see how variable change throughout the flow? I guess a debugging window would kinda defeat the concept of a code free build.

Here’s the problem… you have to think of every block as a function. Each block is in essence returning a value. So when you do this:

Then Thunkable compiles those blocks by first getting the value of app variable 1st counter (let’s say it’s 0) and then looking for an app variable with that name (in this case, app variable 0) but it doesn’t exists so it fails.

When you change an app variable, use the change app variable 1st counter block at the top of the Variables drawer rather than the dynamic block at the bottom that requires a variable name.

No. This is sorely needed and has been requested before.

I use a workaround method for stepping through the code and debugging a project. The link is below.

·····················································································································
Need help? How to Ask Great Questions :sparkles: Debugging A Project :sparkles: API JSON Tutorial

Want to hire a Certified Thunkable Expert? Elevate your app with Tatiang on Fiverr

The above was my testing code while I tried to puzzle out why I could not get a while loop to work.
The below are the blocks I am working on. While loop no longer there in this version.
The interesting part is that, in the below, the labels do increase and pull the next word from the database. So, the word number must be increasing. But when the Word Number is read, it is not incremented. Same with Cycles, which was my While count variable.

Block flow is also confusing me. My main click should call the Update Word function. Which will update the labels, and then speak both labels. The button then finishes by saying the Word Number and the Cycle variables. Just so I could “watch” them increment. It then increments the variables.

But the flow does not seem to follow that path. It will say the Word number and the Cycles before it goes to the French and English words. It does seem to be going top down, because it does read the Word Number before the Cycles. I’m just very confused by something which should be very simple.

Thank you. You posted while I was putting together my follow-up. Let me see if I can wrap my head around your explanation.

Thank you.

I understand now.
I was calling the value of the variable as the the name of a variable. Thank you.

1 Like

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