setting random values based on array

I'm trying to assign a random value from a predefined array. For example i have an array and i want to assign a random value from my array to the height of my selected boxes.

myArray = #(10, 20, 30, 40)
for i in selection do
(
i.height = random (myArray)
)
i know this doesn't work but it the best way to show what i am trying to achieve. I only want the new heights to be 10, 20, 30 or 40 as per array values.

Any help would be much appreciated.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ce89's picture

barigazy, Thank you for your

barigazy,

Thank you for your help, that work's great. It makes complete sense now I see it, but then again it always does afterwards :-)

Thanks again.

barigazy's picture

...

myArray = #(10, 20, 30, 40)
for i in selection do (i.height = myArray[random 1 myArray.count])

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.