randomize

Seeds the pseudo-random number generator with an
integer number, ensuring repeatable number patterns.

randomize(number [, algorithm]) → returns numeric

Argument Reference

number numeric
Required

algorithm string
Default: CFMX_COMPAT

The algorithm to use to generated the random number.
Values:
  • CFMX_COMPAT
  • SHA1PRNG
  • IBMSecureRandom

Examples
Sample code invoking the randomize function

The following example calls the Randomize function to seed the random number generator and generates 10 random numbers.

<cfset randomize(12345)> <!--- if one was to remove this line, the random numbers are different every time ---> 
 <cfloop index="i" from="1" to="10"> 
 <cfoutput>#rand()#</cfoutput> 
 </cfloop> 

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub