Any ideas on how I would keep track of the level of recursion? I'm recurring away, populating a 2-tier array. As I increase levels, it's simple enough to add 1 to know I am at a deeper level. However, as I go back down, I am not sure how I keep track of where I left off:
Assuming I am doing recursive to create the list below, how do I know, when Level 4 ends, that I go back to Level 2, as there are no more Level 3s? Level 1 --> Level 2 --> Level 2 --> --> Level 3 --> --> --> Level 4 --> Level 2 My initial thoughts involve dynamically named variables, but I am also considering being lazy and just keeping the level of the item in a field in the DB. Anyone have a quick fix? Chad who examines life in a recursive manner... just like he did yesterday On 5/10/05, Chad Renando <[EMAIL PROTECTED]> wrote: > Definitely a start, thanks guys, I'll see where I end up. > > As far as the end result, it will vary. I am playing with a new > Framework / MVC-style, so a recursion-style operation will capture the > data to return, another will loop through and present the data, and > another will loop through submitted info to input into the database. > > Chad > who tested validation where variables.WittySig EQ NULL. Test successful. > > On 5/10/05, Brett Payne-Rhodes <[EMAIL PROTECTED]> wrote: > > Hi Chad, > > > > Yes, recursion is certainly possible in CF5, I've used it on a number of > > occasions, even in 4.51. > > > > I've generally used custom-tags but I'd guess you could also use UDFs > > and it can be quite simple... > > > > In pseudo code... > > > > In a custom tag file called getDataRecurs.cfm: > > > > <cfquery name="myQuery" ...> > > select * from myTable > > where parentId = #attributes.parentId# > > </cfquery> > > > > <cfloop query="myQuery"> > > ... Do something here *before* procesing children > > <cf_getDataRecurs parentId="#myQuery.itemId#"> > > ... Do something here *after* procesing children > > </cfloop> > > > > In the code where you want to process the data you would simply use: > > > > <cf_getDataRecurs parentId="0"> > > > > Assuming you have top level items with parentId's of 0, otherwise put in > > whatever ID you need to show just that part of the tree. > > > > Let me know if you need a more comprehensive example. > > > > Regards, > > > > Brett > > B) > > > > > > Chad Renando wrote: > > > Hey all. I am still old-chool CF5, should have access to CF7 this > > > week. However, I have yet to get my head around cfscript, functions, > > > and CFCs. > > > > > > I am wanting to do a recursive thing. I have a table with FieldID, > > > FieldName, ParentFieldID. > > > > > > I want to call all fields where ParentID = 0, then recursively call > > > all fields where ParentFieldID = FieldID, then start over at thge next > > > 0 value ParentFieldID. > > > > > > Currently, I am manually cflooping, no recursion. > > > > > > Is this possible in CF5, and if so, how? > > > > > > I wouldlike to know best practive with functions, but is it also > > > possible without functions? > > > > > > Cheers, > > > > > > Chad > > > > > > --- > > > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > > > To unsubscribe send a blank email to [EMAIL PROTECTED] > > > Aussie Macromedia Developers: http://lists.daemon.com.au/ > > > > > > > -- > > Brett Payne-Rhodes > > Eaglehawk Computing > > t: +61 (0)8 9371-0471 > > f: +61 (0)8 9371-0470 > > m: +61 (0)414 371 047 > > e: [EMAIL PROTECTED] > > w: www.ehc.net.au > > > > --- > > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > > To unsubscribe send a blank email to [EMAIL PROTECTED] > > Aussie Macromedia Developers: http://lists.daemon.com.au/ > > > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > To unsubscribe send a blank email to [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ > --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
