I thought I’d share a process I use for debugging my projects. It involves creating a function that can be used over and over throughout the code blocks in order to help determine where things are going wrong, whether or not certain blocks are ever triggering, and what the values of several variables are.
The real power comes from being able to quickly change the delay (and even set it to 0 seconds) or just remove the contents of the function so that it doesn’t run at all when you’re ready to publish. I cover all of that in the video.
If you want to try out the project yourself: Thunkable
And a video that shows how to do this and explains why I do it this way:
I found the issue, When I add the dvl or dvg and select the data source, it crashes, When I removed the data source it works. But i need that dvl. What to do?
I then tried to get them to work to find my issues by adding a User_Values_Label to the Debug blocks. The plan was to find if my Login Page was searching for my Username during the Login process.
Okay so it runs through the loop and completes the set of blocks in when Debug Click and successfully displays 1, 2, 3, 4, 5, end. Did that answer your question?
Hi @tatiang, I’m afraid it doesn’t answer my question because as my Login Screen loads, it stops at the loading icon. This suggests to me that it, either, for some reason has stopped finding the Firebase Sheet with Member details or it somehow has stopped verifying the sheet details. In which case, how can this Debug operation run through my Firebase sheet and not find anything wrong? Or, is the Debug operation not checking the Firebase Members sheet? I really don’t understand what it is that I am doing.
Are my blocks correctly set up to check my Firebase sheet? If not, how do I do this?
The when Debug Click set of blocks doesn’t have anything to do with your Firebase data, as far as I can tell.
Now that you have a Run_Debug function, add it to the SignIn block because that’s where you want to see what’s happening. So inside of SignIn, add the function a few times to see where it works (displays the message) and where it doesn’t.
Edit: actually, now that I look more closely, you’re not using any Firebase blocks except the SignIn. So I’m not sure how much good that type of debugging is going to do. But I’d still try it!
More importantly, you need to debug the getUser function as I think I mentioned earlier. That’s where I’d focus my time. Check that the list of values blocks are returning the values you expect them to. Don’t rely on those blocks without double-checking.
I think you misunderstood the purpose of the debugging function. It doesn’t tell you anything by itself. All it does is display a value and then wait so you can read that value on the screen.
It’s no different than using these blocks:
Set label’s text to “1”
Wait 1 second
But I got tired of adding and configuring those blocks over and over again so I made a function to save me time.
So why use them? Well, what I usually do is to space the debug function throughout any blocks that don’t seem to be working. Like this
That way, when I preview my project, if I only see “1”… “2” then I know the code stopped working between where I have debug “2” and where I have debug “3”. Then I can add more debugging functions between those to further narrow down what is causing the problem.
But it’s possible that all of the blocks run and I see “1”… “2”… “3”. Then what? Well, in your case you might set the debug function to display the value of each of your variables in the getUser function. That way you can see if their values are what you expect them to be. Or you might display the number of rows in your data source. Maybe you think it’s 25 but it’s really 600 or 10. That happened to me recently.
So the debug function can help to show you values while your project is running rather than only at the end. It helps to slow things down so you can figure out where something went wrong.
If it still doesn’t make sense, share a new project link and I can provide a screenshot of your blocks with debugging blocks added.
Hi @tatiang, I sort of understand a little better but I still don’t really know where I should put these blocks or how they would fit. Below, I have attached a project link, as requested, for you to look at.
Here’s how I would set up the blocks. The basic idea is that each time you set a variable value, you then display that variable. And I would probably increase the wait time in the Run_Debug function to 1 or 2 seconds so you have enough time to see the values that appear.
I don’t understand the video. It’s looping through numbers 1-5 which I suggested is not that helpful. Where are the debugging values inside of the getUser function (“index”, “username”, etc.)?