Strange Issue in Block

Hi, i wrote a code to build a ColinTreeListview following 3 step :
1- Get datas ('n' times in a loop = Nbr_Report) trough Firebase and store the result in a list
2- Display the list in ColinTreeListview
3- Add new data in this ColinTreeListView in the specific field "ExtraButtonTextr"
See Blocks code following


The strange issue is : I need to click twice on Btn_Load, like if i need to launch twice the routine to get the correct result :
The fist click, nothing is displayed, the second, perfect, all is displayed ?!
Could someone explain me why or how to get the result in one pass ?
Many Thks

I'm not familiar with ColinTreeListView, so I'll assume for now that there's something wrong with the Button.Click method. Could you please introduce a label, and then set its text to global flag and global Nbr_Report's values, and then take a screenshot of you running it? I suspect that something might be happening in the while loop.

Hi, Thks for your reply.
I've introduced 3 labels to monitor what's happend :
Label2 is the number of elements to get from firebase. It's initialized to 7.
Label3 is the counter for the loop and is incremented each time we read a record
Label4 is filled when the second proc is done (step 3)
New blocks :


Screenshoot before click :
image
Screenshoot after the 1st click :
image
And final screenshoot after a 2nd click to the button
image
I don't understand why i need to click a second time to get the list displayed ?
Thks

Probably because you call the Chg_Total procedure AFTER you set the CTListview. One your first click you just get the Set, on your second click you will get the set and the Chg_Total.

Try setting the CTListview after running the Chg_Total procedure

1 Like

Hi TIM,
If i call Chg_Total before to set the list, after my first click i got the same screenshoot as above (With 7,8 and no text in label 4) and nothing else.
Then, after the second click i got :
image

I can add that the ColinTreeListView is initialized when the screen is intialized
image

Hi, i also tried to exit the call Chg_Total and just finish by the Call ColinTreeListView
The result is same as the 3 screenshoot above, except that in the last screen shoot there is no value in the gray area (extrabutton) which is normal because there is no call to Chg_Total.
But the program still need to be click 2 times to get the list displayed....
I'm stuck :grimacing:

Hmmm, I have just run a little test and all seems to work on first click:

image

1 Like

Can you show the content of your list global ListFull and global List_Total? Not sure why you are having to do all that text substitution....

I also believe, as @NishyanthKumar says, it is something to do with your while test - normally i would not use this...

1 Like

Hi Tim,
I did the following modifications


Then i got the two lists in label.text
image
But again i had to click twice ...
I think you're right the while test seems to be hte pb

Try replacing the while test with an if/else block

1 Like

When you get data from Firebase, it is not available until the FireBase .GotData event.

So move your display code out of the button click event and into the FireBase .GotData event.

1 Like

Hi, thks TIm & ABG

I tried to move the display code into the firebase.gotdataevent and ... it's ok :slight_smile:
But the call Chg_total procedure don't now fill the values in the extra_button ...

and when i had a label to check List_Total befor to call Chg_Total, i got and empty field ?
image
Yet i build the variable List_Total into the firebase got.event ...

That needs to move also, since it affects the display eventually.

1 Like

That Chg_Total procedure looks fuzzy as to its intentions.

What is it supposed to do?

  • add just a single item to your display, or
  • reset your display to match the current contents of a global list, or
  • add all the items in a global list to your display?

I also have issues with when the best time to call that procedure arises:

  • after each new datum arrives from FireBase, or
  • only after you are sure the last item from FireBase has arrived?
1 Like

Hi, fuzzy ...
Hum,
-1-
In the ColinTreeListView we only can display 1 Picture and 2 Texts Elements
But i was needing another Field (in my cas to report the Total).
Then I decided to use the Extrabutton Text for store the total. (So just an item by line)
-2-
After each new datum arrives. I Built a procedure to store all Total, i did'nt find another solution before.
-3-
Regarding your last advice i move the last display into the firebase event and it seems that now it's run correctly !

Difficult for me to understand this way to run and these subtilities ...
In my past when i was calling a subfunction, the operation just after the call was executed only then the call was finished.
But OK, Now it's perfect, great thks to you and to all reader for their contribution ! :grinning:
Final Screen Shoot
image

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.