Problem with Local DB

Hi, I have a problem displaying the contents of a table using Local_DB.

I created a table in design mode.

02

The app looks like this:

with the rolling blocks:

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.

What is my mistake??

You need to touche the screen before you see the content I’m I right ?

This is the link to my problem app

https://x.thunkable.com/copy/35c202f896a96a43443b85384bd536ba

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

Hi,

Check your corrected example.

https://x.thunkable.com/projects/5dd58fce3828ad79fca11703/project/properties/designer/

Hi actech, thank you very much for that working solution.
But why is the workaround wit a list necessary?

Do you know a reason why my solution with adding each row to the text and then outputting it does not work?

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.

Link to app:
https://x.thunkable.com/copy/e334df1992d4eaf93cf6d07e9562116a

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.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

@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.

I can’t see any difference in the structure here - did you do something else, like copy or rename variables along the way that might be causing this?


UPDATE:

Looking a little more closely I spotted this unused j variable. Did you create and delete another loop?

By renaming your i variable to counter I was able to get everything working properly.

I’m not sure right now why this is happening - but at least it sheds some light on what might have happened.

Thank You Domhnall,

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.