You haven't scoped "i" which means it lives in the unamed scope, 
which is shared across the entire component.

If you want "i" to have a meaning that's local to the function 
you're in, then declare it by doing something like

<cfset var i = 0 >

right after your <cffunction> and <cfargument>. ISTR there are 
problems with doing this declaration in CFSCRIPT inside a CFC.

Andy


--- "Paul Johnston" <[EMAIL PROTECTED]> wrote:
> I have this code with which I am testing a theory:
> 
> ---------code---------
> <cfcomponent>
>       <cffunction name="a">
>               Starting<br>
>               <cfscript>
>                       for(i = 1; i lte 3; i = i + 1) {
>                               b(i);
>                       }
>               </cfscript>
>               <cfscript>
>                       for(i = 1; i lte 3; i = i + 1) {
>                               c(i);
>                       }
>               </cfscript>
>               Ending<br>
>       </cffunction>
>       <cffunction name="b">
>               <cfoutput>b(): #arguments[1]#<br></cfoutput>
>       </cffunction>
>       <cffunction name="c">
>               <cfoutput>in c(): #arguments[1]# ...</cfoutput>
>               <cfloop from="1" to="#randrange(10,100)#" index="i">
>                       <cfhttp url="http://mickey:8000";></cfhttp>
>               </cfloop>
>               <cfoutput>... exiting c()<br></cfoutput>
>       </cffunction>
> </cfcomponent>
> ---------code---------
> 
> Now (on my system) if you invoke the function a,  it runs b() 3 
times and
> c() only once.  If you remove the loop in c(), then c() also runs 
three
> times.
> 
> I wasn't expecting this.  Is this what is expected? Can anyone 
reproduce
> this?  How do I get around it?
> 
> Paul
> -----------------------------------
> Paul Johnston
> PJ Net Solutions Ltd
> http://www.pjnetsolutions.com
> [EMAIL PROTECTED]
> +44 (0)7866 573013
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to