Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recursive Includes and Variables

Status
Not open for further replies.

tyrant1969

Programmer
Dec 13, 2004
68
US
I have a CF page that once called has the potential to call itself recursively. This is done via the CFINCLUDE statement.

Prior to the recursive call a variable is set that affects the font color.

Inside the recursive call the system checks the value of the variable and changes the font to the alternate color. The problem is that when we back out of the recursive call the variable doesn't return to the original value.

Is there some way to define the variable so that it is local to the current iteration of the call?
 
<cfinclude template = "thispage.cfm"> is typically a bad idea. why do you need to include the page from its self? ever consider a loop?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
As to why I use the CFInclude - I run a query then using cfoutput I output the query, some of the results have "children" results. In order to get those children I re-run the query by using the cfinclude statement.

Some of the children have children and so on. There is no advance knowledge as to how many levels down each pattern may go, some of the originals or even some of the children may have multiple results returned which could lead to no further children or to lord only knows how many children.

The cfinclude simply seemed the most prudent way to output results.
 
lord only know" how many children?

what would you say was the absolute maximum depth? five levels? eleven? seventy-two?

because a recursive query (whether you do it with recursion or with a a query inside a loop) is inefficient and there might be a way you can get everything in a single query if there was an absolute maximum depth

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts July 10 2005)
 
What I am working on is, more or less, a family tree. No marriages come into play, only if children are resultant, dead branches (those without children) are shown.

So, we start with original ancestor x number of generations back, original ancestor had 3 offspring, offspring one had no children, offspring 2 had 3 offspring of their own, offspring 3 had 2 offspring.

This is going to go grow.

Currently from the original ancestor there are at least 21 levels of depth, and it is a known fact that in this test entry there are probably 5 or 6 more levels beyond the 21 that currently exist (and come next fall there will be a new addition to the tree).

So, since we have no idea how large this tree is or will be - and the next tree that it is planned to be used on probably has a higher level of depth - recursive iteration is progamatically the easiest way to get the results displayed properly. Now if we could just get the alternatig colors down that would work best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top