Here is the full thing, with support for max, min and decimal places:
Code:
Break ON
$=SetOption("Explicit","ON")
Dim $i,$r,$max,$min
$r=rng(0,0,@TICKS)
While "TRUE" AND Not KBHit()
rng(10.00,20.99) ?
Loop
Function rng($iMin,$iMax,Optional $iSeed)
Dim $vDiscard,$sDecimal,$i,$iFactor
$sDecimal="."
; Establish how many decimals to use
If InStr($iMin,$sDecimal) $iFactor=Len($iMin)-InStrRev($iMin,$sDecimal) EndIf
If InStr($iMax,$sDecimal) $i=Len($iMax)-InStrRev($iMax,$sDecimal) EndIf
If $i>$iFactor $iFactor=$i EndIf
$iFactor=CInt("1"+Left("000000",$iFactor))
; Ensure min and max are in the right order
If $iMax < $iMin $i=$iMin $iMin=$iMax $iMax=$i EndIf
$iMax=$iMax * $iFactor
$iMin=$iMin * $iFactor
; Fix max to base (0)
$iMax=($iMax-$iMin+1)
If Not IsDeclared($_RNG_PERSISTENT) Global $_RNG_PERSISTENT EndIf
If VarType($iSeed) $_RNG_PERSISTENT=CInt($iSeed) EndIf
$_RNG_PERSISTENT=1103515245*$_RNG_PERSISTENT+12345
; Emulate 16 bit shift right ($rng>>16)
$rng=DecToHex($_RNG_PERSISTENT)
$rng=SubStr($rng,2,Len($rng)-3)
If $rng="" $rng=0 EndIf
; Convert hex to Decimal and fix to scope
; $vDiscard=Execute("$$rng=&"+$rng)
$vDiscard=Execute("$$rng=CDbl(((&"+$rng+" mod "+$iMax+") + "+$iMin+")) / "+$iFactor)
EndFunction