thanks brad thats really understandable, much appreciated! >Yes, each time the function recurses into itself you want it to start >over with a new set of variables specific to that particular run. >Unless otherwise specified, your variables such as the query are placed >in the "variables" scope which is global. That means as soon as your >function called itself, it would overwrite the variables from the >previous iteration, and when it returned back to the original iteration, >the variables were not as they had been left. > >Think of recursion as a stack, where every time you recurse back into >your self, you place the previous function call "on hold" on top of a >stack to come back to later. > >There are in fact times when a variable should not be varred, like if >you wanted to keep some global counter of how many times your function >ran or something. In general though most variables (especially result >sets and loop indexes) should be local. > >As a broad rule, all variables should be varred inside of a function or >a method of a CFC if you want them to be local to that method only. If >for nothing else then to make sure you don't inadvertently overwrite >another variable on your page with the same name. > >~Brad > >spot on, thanks brad, works perfectly, > >just so i understand, does this make a difference because then it is >creating a new variable each iteration, and if you don't set it then >just puts it into the existing variable? > >i don't use many vars in my code, is that bad practise? > >thanks again for your help
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306645 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

