Using Random Function Without Repetation and Lists in App Inventor 2
Today i show you how to use “random random integer from” and “make a list” block. The aim of the program is, when i press to button1 i will get a random character from my list. And these characters will not repeat theirselves.
At the top block, i made my variable declarations. Variable bbb is for the maximum value of list’s index. indexno is for the index’s number and datass is my list. Index starts from 1, for example index number of a is 1, and the index number of e is 5.
At this section, when i press the button1 it checks the value of bbb is equal to 1? Reason of that when the value of bbb is 1 it means when we press again button1 there won’t be any element at list. So when it equals to 1 , i make it disable to press.
“Remove from list” takes the certain indexed element from list and places its place with the next one. For example if he function takes the element that has the index number as 2, 3rd element will be the new 2nd element and 4 to 3 and also 5 to 4.
Now, we have disabled press buton and when we press reset, all values will download to the list. Also the maximum value of index. Because there will be no element of my list at the end of the program.