I’m making buttons dynamically on one page, I’m essentially trying to make a new app variable each time a button is created by combining 2 initialized app variables
Idea:
intialized app variable name = var = " ";
intialized app variable name = i = 0;
button created - assigned to var1
button created - assigned to var2
button created - assigned to var3
so on and so on, but I’m begging to think this isn’t possible to do in thunkable. If it is;t possible to do this then how can I make and assign a button to a variable when it’s dynamically created with thunkable?
Thanks for providing both a detailed description of what you are trying to do as well as the blocks you are using. Both are incredibly valuable to the community to make suggestions.
@muneer correctly indicates it is possible, but it may not be advisable. What is your goal? Are you trying to create some sort of array or data-bound form? Depending on the use, there may be a thunkable component better suited to your purpose.
I agree with @drted. I was going to say that I’m always confused about why people would want to use dynamically-named variables but there may be a use case I just haven’t come across.
A list, data source or firebase is almost always going to be more manageable and efficient.
Hi! so in more detail what I’m trying to do is this:
Page 1: So on the first page, the user can make buttons dynamically and that button is stored in a variable with a unique name.
Page 2: when one is clicked they go to this page where the variable of the dynamically created button is referenced, a timer starts on that page and when the user presses stop on the timer, the time of the timer when it was stopped, is set to the text of the clicked button on the first page.
Would a data source of firebase be better in this case?
The component block stores the component’s ID. The ID is a long string of characters like in the screenshot you posted above. You need the button component’s Text. So your blocks would be set app variable “Time” to [get button [component] text].
As @tatiang described, Thunkable uses an internal ID for every component you create. For example, right click on any component and you will see a good example of internal IDs of Thunkable in the pop-up menu.
Another issue is the names you assign to the buttons. I take it you are creating a variable called “Time” in this variable you want to store a text followed by a number. so you need to do something like this
Which, if the text of the button is “Car” then the variable will have the text “Car1”. The way you have done it would yield to trying to increment the the value by 1.