|
| [WM20] - How to randomize (shuffle) an array items order |
| Iniciado por guest, 04,jul. 2017 12:54 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 04,julio 2017 - 12:54 |
Hello,
I am loading values to an array as entered by user.
After enters all the values I want to randomize the array elements order so the user entered values gets shuffled and they are not in the sequence as entered by user.
For this the online help refers to a function called ArrayMix but that function is not available in WM20.
How can the shuffle the values in an array in a random way order?
TIA |
| |
| |
| | | |
|
| | |
| |
| Publicado el 04,julio 2017 - 13:48 |
Hi
Just use the random instruction.
Something like this will do the trick: iRandom is int For i=1 to arraysize //select a random position in the array iRandom=random(1,arraysize) //then exchange that position value with the current one SaveVar=Array(i) Array(i)=Array(iRandom) Array(iRandom)=SaveVar End
That's it
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,julio 2017 - 07:11 |
Fabrice,
Thanks for the code.
I have now got it rolling.  |
| |
| |
| | | |
|
| | | | |
| | |
|