Appears to go through loop less often than intended

For a letter game for children:
the app picks a random letter from a random list and is supposed to write this letter on 7 random buttons out of 49. Why do usually 7 letters appear (as it should be) but sometimes only 6, and once only 5??

The list of buttons, it is to go through, is complete; all buttons have precisely the same settings in the designer, all being visible and so.

You do not show your WriteOnRandomButtons procedure?

My guess is that it is between this procedure and your while test event causing the issue, or you are getting the same button more than once...

Use a for each number in block instead, and ensure your procedure is not doing anything out of turn...

1 Like

This seems to work:

getNumber gets the number to go in the buttons
buttonList is generated in the while test to get a unique list of 7 buttons
previous button settings cleared
new number set to buttonList

3 Likes

I think the problem is that I rely on indexes when picking and later deleting an item from the list rather than using the content. When a used item is deleted from the list, of course, the index can be reused. Therefore, the letter can be written on the same button again.