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 >I'll admit, I only briefly scanned your code, but start by varring all >your local variables including the query at the top of the function > ><cfset var childFolders = ""> ><cfset var ax1 = ""> > >Etc... > >~Brad > >hi > >i am having a problem with a recursive function resetting the contents >of a query, so i must be doing it wrong, can anyone spot what i should >be doing please, thanks > >basically i pass in a folderid and query to see if it has any children, >if it does then it adds the child and goes on to recall if the sub >folder has children. the problem is that when it reaches the bottom and >finds a folder that doesnt have any children then it comes back up a >level and the query is blank. so how can i get it to keep the contents >of an array local to that recursion of the function i.e. when it comes >up a lavel, it remembers the query for that folder > >the recursive function builds up a tree as follows: > ><cffunction name="addXMLFolderNodes"> > <cfargument name="xmlElement" type="xml" required="yes"> > <cfargument name="childXMLCountReference" type="numeric" >required="yes"> > <cfargument name="parentID" type="numeric" required="yes"> > > > <!--- first see if this folder has any children folders ---> > <cfquery name="childFolders" datasource="portexunitich" >username="#session.dbUsername#" password="#session.dbPassword#"> > SELECT * from querytree > where folderParentID = <cfqueryparam value="#parentID#" >cfsqltype="cf_sql_bigint" maxlength="20" null="no">; > </cfquery> > > > > <!--- loop through adding them to the tree ---> > <cfloop index="ax1" from="1" >to="#childFoldersTemp.recordcount#"> > <cfset xmlElement.xmlChildren[childXMLCountReference] = >XmlElemNew(MyDoc, "row")> > <cfset >xmlElement.xmlChildren[childXMLCountReference].XmlAttributes["id"] = >childFoldersTemp.folderID> > <cfset >xmlElement.xmlChildren[childXMLCountReference].XmlAttributes["bgColor"] >= "white"> > > <cfset >xmlElement.xmlChildren[childXMLCountReference].XmlChildren[1] = >XmlElemNew(MyDoc, "cell")> > <cfset >xmlElement.xmlChildren[childXMLCountReference].XmlChildren[1].XmlText = >childFoldersTemp.folderName> > <cfset >xmlElement.xmlChildren[childXMLCountReference].XmlChildren[1].XmlAttribu >tes["image"] = "folderOpen.gif"> > <cfoutput>'#childFoldersTemp.folderID[ax1]#'</cfoutput> > <cfset temp = >addXMLFolderNodes(xmlElement.xmlChildren[childXMLCountReference],2,child >FoldersTemp.folderID[ax1])> > <cfset childXMLCountReference++> > </cfloop> > > </cffunction> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:306640 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

