Page 1 of 1
Random Element
Posted: 27 Jul 2014 05:03
by Akt
Hi
I am using the script getRandomElement(files).
If there are 100 images, is it possible that it dont repeat an image untill all 100 are taken??
I think it keeps on repeating some images and dont open new ones........
Re: Random Element
Posted: 28 Jul 2014 17:31
by Martin
Hi,
You can remove the element from the list so you don't get this element again. Something like this should work:
Code: Select all
file = getRandomElement(files);
removeElementValue(files, file);
Regards,
Martin
Re: Random Element
Posted: 29 Jul 2014 02:13
by Akt
Hi martin
It is now also repeating files without completing all files.....
Please help!!
Re: Random Element
Posted: 29 Jul 2014 16:26
by Martin
Hi,
Please share the flow so we can check what's going on.
Regards,
Martin
Re: Random Element
Posted: 30 Jul 2014 01:20
by Akt
Re: Random Element
Posted: 30 Jul 2014 18:57
by Martin
Hi,
You could read the list of files into a global variable once a day or once a week and use a second flow that displays a random image:
Flow 1
-trigger ...
-action
Init Variable File List variable
global_files
Flow 2
-trigger ...
-action
Script
Code: Select all
file = getRandomElement(global_files);
removeElementValue(global_files, file);
-action
Start Activity: ...{file}
Regards,
Martin