The function is simply to create a text with every row from 1 to NumberOfRows followed by a newline and display this text of the complete table in Label5.
Pressing Button2 gives the correct number of rows in Label3 but sometimes displays parts of the table, after first press nothing and sometimes the correct table.
Okay yeah you have a kind of the same problem like I have i might think… @domhnallohanlon I think they are all ready looking for this problem but I’m not sure but yes I tested your app right now and to see label3 we need to touch scroll the screen before anything show up
Your example, like the examples of other users, does not work due to the use of blocks of global app-variables. After the new Live update, I see problems with their use, as well as other problems associated with updating the data and displaying it on the screen.
I think the developers will be able to fix this after a while.
You probably noticed that in my examples I use variable blocks from function parameters, and not global variables? This is not a coincidence. They have a fundamentally different mechanism of operation and blocks of variables from function parameters work more reliably and correctly from a programming point of view.
You are right. In my first solution it also works when I do not use a global variable. But I only can create a „local“ variable by renaming one of the counters of a loop to use it for the text. With that my solution also works.
But how can I create such a local variable without „tricks“?
This question is compatible to my former thread about local variables.
It seems to me that the lack of local variables is more essential than I thought before.
This seems to be the „cleaner“ solution.
Passing the text to the function as parameter and then returning the result means that we really use local data (parameter).
By the way: Playing with this example shows me that the parameter concept of thunkable only uses parameters of type „call by value“. Parameters of type „call by reference“ are not availiable.
Your solution is suitable for explaining the concept of a local variable, but it is also tied to a parameter.
Passing a parameter by reference also works in Thuinkable X. This is just the difference between the way the variables work. Variables from function parameters have a link mechanism of operation, in contrast to global variables that even work with objects by value.
Below is an example of blocks from my course, which shows a ref to an object and copying an object.
@rollke just to go back to your original post here. When I click “Ausgabe” the label with the row count is correct, however I have to click the button a second time to display any text.
Then I recreated your blocks, testing one variable at a time to see if I could reproduce any errors, and for the screen opening and for the button press event everything seems to work fine.
in my original, older version with the mistakes caused by the output, I also changed the predifined counter variable in the loop to “counter”. And indeed now the app runs correctly with the immediate output of all the data of the Local_DB.
But in a different app, using the same function “Ausgabe” it does not work with changing the counter variable. But this function works, when i use the trick to create a “local” variable using a local counter variable of a different loop, rename it and use it in the function.
So there must be a problem when using global variable (app ausgabetext). Renaming a counter variable of a different loop to “ausgabetext” (without app…), then it works.
You see, we really need local variables.
But what is the reason?
It would be helpful for all thunkers to know.