Random number between two variables.

I have a GUI which is bound two numerical variables (TimeMin and TimeMax) and I want to generate a random number between these two, and set it to a final variable (preferably as a number) called TimeMaster, but all that seems to happen is that it choses the TimeMax variable

My code at the moment is

set TimeMaster to (random number from (TimeMin as number) to (TimeMax as number))

Thank you in advance for any support.

Try “as integer” or “as real” depending on which you want – that worked when I tried it. “As number” just gave me an error message rather then the max value.


I agree with rdelmar. Stopped using “as number” since switching to ASOC, somehow never worked. “as real” or “as integer” always worked fine.

Browser: Safari 6533.18.5
Operating System: Mac OS X (10.6)

Cheers that worked, the problem isn’t with that piece of code, it is with my bindings to a checkbox which deterimines whether to choose a random number or to use the max value
Thank you for your support