RandomEx doesnt work with variables - Forum

Forum Navigation
You need to log in to create posts and topics.

RandomEx doesnt work with variables

So I am just testing things out. Just wanted to get a random number between a min and max number. So I made 2 text input objects. One with the variable [min] and one with the variable [max]. In a button action I put the following code:

RandomEx [min] [max] [x]
Math "[z]-[x]" 0 [z]

I have the [min] set to 5 ad the [max] set to 55

[x] gets results varying from 67 to 2479 in a few tries. Not even remotely close to anything that makes sense.

nevermind lol, I'm such a noob. I added this:

ToNumber "[min]" [min]
ToNumber "[max]" [max]

And it works like it should

Hi @mazzu001, I noticed standard random functions are not as random especially during the first few tries, but getting better subsequently. One workaround I did is to shuffle the random numbers, like an array, a series of poker cards.  You might want to check on my posting “shuffling array numbers” that used to generate random number. Simply replace the max number variable and the loop from.. as the minimum number. You can then decide which array item to use

Fantastic Code Ronnie. Thank you a ton for sharing. Appreciate that a lot