Randomize(DateFormat(now(),"ddmmyyyy")&TimeFormat(now(),"hhmmss"));
NewNumber = RandRange(1,99999999);
Any particular reason???
Stephen
Tony Weeg wrote:
> <cfobject name="randomGenerator" component="randomGenerator">
> <cfoutput>
> <cfloop from = 1 to = 50 index = i>
> <cfinvoke component="randomGenerator" method="next"
> returnvariable="theNumber">
> #theNumber#<BR>
> </cfloop>
> </cfoutput>
>
> Is what I have, and here are the results, am I doing something
> wrong?
>
> 3582162
> 3582162
> 3582162
> 3582162
> 3582162
> 3582162
> 87279085
> 87279085
> 87279085
> 87279085
> 87279085
> 90357076
> 90357076
> 90357076
> 90357076
> 90357076
> 90357076
> 81123102
> 81123102
> 81123102
> 81123102
> 81123102
> 85162966
> 85162966
> 85162966
> 85162966
> 85162966
> 85162966
> 75928992
> 79006983
> 79006983
> 69965384
> 69965384
> 69965384
> 69965384
> 69965384
> 73043375
> 73043375
> 73043375
> 73043375
> 73043375
> 73043375
> 12480138
> 12480138
> 12480138
> 12480138
> 12480138
> 15558129
> 15558129
> 15558129
>
> and here is the code in the cfc
>
> <cfcomponent output="no">
>
> <cfset my = structNew()/>
> <cfset my.rnd = createObject("java", "java.util.Random").init()/>
> <cfset my.min = 0/>
> <cfset my.max = 99999999/>
> <cfset my.cnt = 0/>
>
> <!-- Set the minimum and maximum. --->
> <cffunction name="setBounds" access="public" returnType="void"
> output="no">
> <cfargument name="min" type="numeric" required="true"/>
> <cfargument name="max" type="numeric" required="true"/>
> <cfset my.min = arguments.min/>
> <cfset my.max = arguments.max/>
> </cffunction>
>
> <!--- Set the maximum. The minimum is automatically 0. --->
> <cffunction name="setMax" access="public" returnType="void" output="no">
> <cfargument name="max" type="numeric" required="true"/>
> <cfset my.max = arguments.max/>
> </cffunction>
>
> <!--- Sets the seed. Accepts ints and longs (but no decimals). --->
> <cffunction name="setSeed" access="public" returnType="void"
> output="no">
> <cfargument name="seed" type="string" required="true"/>
> <cfset var l = createObject("java",
> "java.lang.Long").init(arguments.seed)/>
> <cfset my.rnd.setSeed(l.longValue())/>
> </cffunction>
>
> <!--- Returns the next highly random number. --->
> <cffunction name="next" access="public" returnType="numeric"
> output="no">
> <cfif my.min + my.max eq 0>
> <cfreturn my.rnd.nextInt()/>
> <cfelse>
> <cfreturn (my.rnd.nextInt(javaCast("int",((my.max+1) - my.min)))
> + my.min)/>
> </cfif>
> </cffunction>
>
> <!--- Returns a random boolean. --->
> <cffunction name="nextBoolean" access="public" returnType="boolean"
> output="no">
> <cfreturn my.rnd.nextBoolean()/>
> </cffunction>
>
> </cfcomponent>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

