Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Random Numbers within a range

$
0
0
Im fooling with some random numbers and i think im making hard work of it so im asking is there an easier way to do this?

I make some random numbers like this
[ autoit ]      
 $RandStart1 = Random (48, 57, 1) ;48-57 $RandStart2 = Random (65, 90, 1) ;65-90 $RandStart3 = Random (97, 122, 1) ;97-122 ;==================================================== $RandMid1 = Random (48, 57, 1) $RandMid2 = Random (65, 90, 1) $RandMid3 = Random (97, 122, 1) ;==================================================== $RandFinish1 = Random (48, 57, 1) $RandFinish2 = Random (65, 90, 1) $RandFinish3 = Random (97, 122, 1)
Then i mix them up like this
[ autoit ]      
 For $i = 1 To Random(2, 4, 1) $sText &= Chr(Random($RandFinish3, $RandStart3, 1)) $sText &= Chr(Random($RandMid1, $RandStart1, 1)) $sText &= Chr(Random($RandFinish2, $RandStart2, 1)) $sText &= Chr(Random($RandStart2, $RandMid2, 1)) $sText &= Chr(Random($RandStart1, $RandMid1, 1)) $sText &= Chr(Random($RandMid3, $RandFinish3, 1)) StringTrimLeft($sText, Random(13, 19)) Next
Its a bit long winded i feel

the 3 types have to be Ascii numbers  48-57 (1-0) / 65-90 (A-Z) / 97-122 (a-z)
i run this three times and add them together to create a 25 - 40 ish long set of numbers letters etc
I dont need military grade random or anything severe just a easier way.

Any suggestions?

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>