Chapter 2: ColdFusion Functions
489
Randomize
Seeds the random number generator in ColdFusion with the integer part of a number.
By seeding the random number generator with a variable value, you help to ensure
that the Rand function generates highly random numbers.
See also
Rand
and
RandRange
.
Syntax
Randomize
(
number)
number
Any number.
Usage
Call this function before calling
Rand
. Although this function returns a decimal
number in the range 0 to 1, it is not a random number and you should not use it.
Examples
<!--- This example shows the use of Randomize --->
<HTML>
<HEAD>
<TITLE>
Randomize Example
</TITLE>
</HEAD>
<BODY BGCOLOR=silver>
<H3>Randomize Example</H3>
<P>Call Randomize to seed the random number generator.
This helps to ensure the randomness of numbers generated
by the Rand function.
<CFIF IsDefined("FORM.myRandomInt")>
<CFIF IsNumeric(FORM.myRandomInt)>
<CFOUTPUT><P><b>Seed value is #FORM.myRandomInt#</b>
</CFOUTPUT><BR>
<CFSET r=Randomize(FORM.myRandomInt)>
<cfloop index="i" from="1" to="10" step="1">
<CFOUTPUT>Next random number is #Rand()#</CFOUTPUT><BR>
</cflooP><BR>
<CFELSE>
<P>Please enter a number.
</CFIF>
</CFIF>
<FORM ACTION="randomize.cfm" METHOD="POST">
<P>Enter a number to seed the randomizer:
<INPUT TYPE="Text" NAME="MyRandomInt">
<P><INPUT TYPE="Submit" NAME="">
</FORM>
</BODY>
</HTML>
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...