Random Element

Post your questions and help other users.

Moderator: Martin

Post Reply
Akt
Posts: 133
Joined: 25 May 2014 08:57

Random Element

Post by Akt » 27 Jul 2014 05:03

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........

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Random Element

Post by Martin » 28 Jul 2014 17:31

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

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Random Element

Post by Akt » 29 Jul 2014 02:13

Hi martin
It is now also repeating files without completing all files.....
Please help!!

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Random Element

Post by Martin » 29 Jul 2014 16:26

Hi,

Please share the flow so we can check what's going on.

Regards,
Martin

Akt
Posts: 133
Joined: 25 May 2014 08:57

Re: Random Element

Post by Akt » 30 Jul 2014 01:20


User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Random Element

Post by Martin » 30 Jul 2014 18:57

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

Post Reply