What I have done in the past is to use

<cfset duplicatevalue = 1>
<cfloop condition="duplicatevalue eq 1">
    generate random value...
    if random value not in list then...
    <cfset duplicatevalue = 0>
<cfloop>

HTH - Dan

----- Original Message -----
From: Francis, Jennifer <[EMAIL PROTECTED]>
To: CF-Talk <[EMAIL PROTECTED]>
Sent: Tuesday, May 22, 2001 4:54 PM
Subject: Pre test / Post test


> I'm trying to create a pretest/post test with the same questions except
for
> the order changes for the post test.  The question numbers & questions are
> stored in the database, so I just need to pull them by the question
number.
> I have tried to use randrange, but it creates duplicates.  Is there an
easy
> way to make sure the list does not contain any duplicates?
>
> Here's what I have so far...
>
> <cfoutput>
> <cfset randlist="">
> <cfloop index="i" from="1" to="10">
> <CFSET randques="#randrange(1,10)#">
> <cfif listcontains(randlist, randques)>
> <CFSET randques="#randrange(1,10)#">
> </cfif>
> <cfset randlist=listappend(randlist, randques)>
> </cfloop>
> #randlist#
> </cfoutput>
>
>
> Jennifer Francis
> AT&T Wireless
> * [EMAIL PROTECTED]
>
> AT&T Proprietary - Use pursuant to company instructions
> Attention:  Information contained in this EMAIL, including attachments,
may
> contain sensitive or AT&T proprietary information.  Please use pursuant to
> company instructions.  Take care not to disclose proprietary information,
> and forward this EMAIL and its attachments with caution only to those that
> have a need to have this information.
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to