Please Help. I can;t use loop (count with or repeat)

test

If I run this, It only set my Label ID4 not ID 0,1,2,3.
I don’t know why. Please help me.

1 Like

I would venture that the loop simply runs too fast, garbles and overwrites the requests.

Add a “wait” instruction in the loop and see if that helps.

1 Like

Or you may try a for each item in list loop…
(as @CBVG said, count with i is too fast; for each loop is comparatively slower :smile: )

image

Thanks! :blush:

It worked : )

1 Like

Can you show your blocks with the delay?

And also your app user interface?

Sorry it worked after more than 1 sec delay.
I really appreciate that! : )

Now, I will explain why you needed this delay.

Realtime is cloud based. Unlike a local variable which is immediately accessible because it resides in your own device, accessing data on the web means a process is required to package the query, send it over, wait for the destination to acknowledge it, process it and reply. If the remote server gets several requests in quick succession, it may have the first answer ready only after it got the 4th request in. So, the system will probably want to package them all in a single answer instead of sending them separately, because it is more efficient.
And that is the problem: you got all the answers on top of one another. Their “efficiency” just killed you.
It is even possible that there may be a time where 1 second delay could be not enough, if communication is poor.

2 Likes

Using a delay block when working with data is an unreliable solution. If you need a reliable solution, then you need to change the data structure so as to replace several cloud calls with list work. To do this, create a root node and transfer all your nodes to it. After this, the root node data is requested to the list once. After that, access to the child nodes occurs locally.

2 Likes

Thanks for advice. I’m not knowing about node. But It seems like I should call request to my server just once. Then my next step is call my all cloud date to my local DB right?
Can you explain with blocks?

You got it right.

Your nodes in the database have the structure:

0/id
1/id
2/id
3/id
4/id

And you need to do this:

idnodes
    0/id
    1/id
    2/id
    3/id
    4/id

Now you need to access the idnodes node and use the “get object properties of” block to get a list of child nodes - 0/id…4/id.

Do you understand this explanation?

Thanks. Now I know what is problem.

but I don’t know about “get object properties of”.
I should read something or example.

Should I edit my DB too?

scrFirebase tap button “Get properties”

Should I edit my DB too? Yes

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

1 Like

Oh my,
Thanks sir. I really appreciated.
I just start thunkable 1 week ago.
I’m growing by your help. I will study this!
Thanks a lot.

2 Likes

I wish you success! Creating applications on Thunkable X is very interesting!

2 Likes

OMG Success. Thanks a lot!
I dont need a delay now.
But it loaded long time (about 5~6 sec)
Is there a solution?

test5

1 Like

But it loaded long time (about 5 ~ 6 sec)

I did not understand what the loaded is so slow? Firebase have to work very quickly.

You can measure the speed of operation as shown below?

It is not right. Here you need to specify the Label component, as you pointed out some obscure text. Therefore, the program is looking for a long time Label with name “IDi” and can not find. Therefore, these brakes. Simply put, you are using an incorrect parameter in the block. I am surprised that the program works at all after that and did not crash. See "Any Component" Blocks - ✕ Docs

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

Sorry. I can’t understand. I have 50 ID0-49 so I use IDi. O can’t imagine another way​:sob::sob::sob: What is another parameter? I read that docs but I couldnt find

Now I’ll give you an example.

1 Like

Look at the example of the updated scrFireBase screen when you press the button btnGetProperties. Now you understand how it works?

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

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

My data

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

> I have 50 ID0-49
I do not understand, you have created 50 Label with the names of ID0-49?

2 Likes