Adobe COLDFUSION 9 Manual page 722

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<html>
<head>
<title>Your Magic numbers</title>
</head>
<body>
<h1>Your Magic numbers</h1>
<P>It will take us a little while to calculate your ten magic numbers.
It takes a lot of work to find numbers that truly fit your personality.
So relax for a minute or so while we do the hard work for you.</P>
<h2>We are sure you will agree it was worth the short wait!</h2>
<cfflush>
<cfflush interval=10>
<!--- Delay Loop to make is seem harder. --->
<cfloop index="randomindex" from="1" to="200000" step="1">
<cfset random=rand()>
</cfloop>
<!--- Now slowly output 10 random numbers. --->
<cfloop index="Myindex" from="1" to="10" step="1">
<cfloop index="randomindex" from="1" to="100000" step="1">
<cfset random=rand()>
</cfloop>
<cfoutput>
Magic number #Myindex# is:&nbsp;&nbsp;#RandRange(
100000, 999999)#<br><br>
</cfoutput>
</cfloop>
</body>
</html>
Reviewing the code
The following table describes the code and its function:
Code
<h2>We are sure you will agree it was worth the short
wait!</h2>
<cfflush>
<cfflush interval=10>
<cfloop index="randomindex" from="1" to="200000"
step="1">
<cfset random=Rand()>
</cfloop>
<cfloop index="Myindex" from="1" to="10" step="1">
<cfloop index="randomindex" from="1" to="100000"
step="1">
<cfset random=rand()>
</cfloop>
<cfoutput>
Magic number #Myindex# is:&nbsp;&nbsp;#RandRange
(100000,999999)#<br><br>
</cfoutput>
</cfloop>
Description
Sends the HTML header and all HTML output to the cfflush tag to the
user. This displays the explanatory paragraph and H2 tag contents.
Flushes additional data to the user whenever at least 10 bytes are
available.
Inserts an artificial delay by using the Rand function to calculate many
random numbers.
Generates and displays 10 random numbers. This code uses two
loops. The outer loop repeats ten times, once for each number to
display. The inner loop uses the
by generating more (unused) random numbers. It then calls the
RandRange function to generate a six-digit random number for
display.
Last updated 8/5/2010
Rand
function to create another delay
717

Advertisement

Table of Contents
loading

Table of Contents