Jump to content
Sign in to follow this  

random number generator

Recommended Posts

This is a very nice script thank you!

i just have one question? how does it Randomize without Repetition once

you shut the program down or does it?, I would like to add one column

and enable a right click option to select entire column for copy and

paste with mouse any tips on getting this fabulous program to create a

log and store to working directory?

I randomly thank you

#include <Array.au3>
Local $iNumbers
Local $iDigits = 4
Local $t = TimerInit()
For $n = 0 To 1000
_RandomEx($iNumbers, $iDigits); Randomize without Repetition
ConsoleWrite('Timer:' & TimerDiff($t) & @CR)
_ArrayDisplay($iNumbers, 'RandomEx | Phoenix XL [' & @ScriptName & ']')

Func _RandomEx(ByRef $aNumbers, $nDigits = 5);Converted from Recursive to Iterative
;All the Possible Numbers have been added return -1 and set @error
If UBound($aNumbers) >= ((10 ^ $nDigits) - 1) - (10 ^ ($nDigits - 1)) + 1 Then Return SetError(1, 0, -1)
Local $vTemp, $nChk = 0
While 1
$vTemp = Random(10 ^ ($nDigits - 1), (10 ^ $nDigits) - 1, 1)
_ArraySearch($aNumbers, $vTemp)
If @error Or $nChk >= (10 ^ ($nDigits/2) ) - 1 Then ExitLoop
$nChk += 1
If $nChk >= (10 ^ $nDigits) - 1 Then $vTemp = _ProbabilityCheck($aNumbers, $nDigits)
Switch IsArray($aNumbers)
Case 0
;Make it an Array
Local $n[1] = [$vTemp]
$aNumbers = $n
Case 1
_ArrayAdd($aNumbers, $vTemp)
Return $vTemp
EndFunc ;==>_RandomEx

Func _ProbabilityCheck(ByRef $aNumbers, $nDigits)
For $n = 10 ^ ($nDigits - 1) To (10 ^ $nDigits) - 1
_ArraySearch($aNumbers, $n)
If @error Then
Return $n;
Return -1
EndFunc ;==>_ProbabilityCheck

Share this post

Link to post
Share on other sites

Im trying to create a random number generator that i can use to scan against the DNC

and upload ok to call #'s into a call plan.

The only issue im having with the script at this time is the ability to copy more than one cell

so i can paste a 1000 or so numbers for scanning.

I don't know where to start searching for documentation on this

or if someone uses a random generator for this purpose and has

better script feel free to post


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...