Recursion to retrieve blog thread - help please

2008-11-05 Thread Christophe Maso
I feel I should know how to do this, but I haven't really had to write a 
function like this yet.

We have a blog site where, currently, users can post entries to their own 
respective blog, and replies can be made to that entry.  Entries are kept in an 
entries table, and replies are kept in a replies table.  Each reply belongs 
to a parent entry, so entryId is a foreign key within the replies table.

I've been tasked with modifying the site so that replies can be made to 
replies, so you can have multi-level threads.  I've done this, by adding 
parentReplyId as a column in the replies table.  Each reply still has the 
entryID of the entry that ultimately started the thread to which it belongs, 
but now parentReplyId gives additional info - if this is null, then the reply 
is a top-level reply, made to an entry directly, and if it is not null, then 
the reply has been made to another reply.  Now it comes down to writing a cfc 
function that will retrieve an entry's reply nodes in the correct order, 
following each reply down the tree until it dead ends and then continuing on 
at the next level up (I'm sure there's a more technical term for this type of 
structure).

So ultimately I'll be able to display reply A on the page with its child 
replies indented below it, and any of their child replies further indented 
below them, etc., until there are no more and its on to reply B...like how 
you see replies displayed on Daily Kos and Livejournal.  I'm really not sure 
how this is typically done in a CFC function, or if I'm best off with 
returntype query, or returntype array, or if maybe this can be done in a single 
SQL query.  But I've a strong feeling that it's done with recursion.  Help 
please?  Thanks,

Christophe 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314869
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion to retrieve blog thread - help please

2008-11-05 Thread Jason Fisher
Original call would look something like this, where entryID is all you need to 
start with:

cfset myReplyTreeQry = getChildren(url.entryID, request.datasource)

This would create a query result called myReplyTreeQry with the following 
columns:
entryID
replyID (of each reply)
parentReplyID (of each reply, not really needed, but good for debugging)
level (of each reply, to help in indenting as you output them)

Obviously, more columns would need to be added to show all the actual Reply 
information, but this works for the recursive structure.

cffunction name=getChildren returntype=query output=no
cfargument name=entryID type=string required=yes
cfargument name=datasource type=string required=yes
cfargument name=parentReplyID type=string required=no default=
cfargument name=rtnQuery type=query required=no
cfargument name=levelCtr type=numeric required=no default=0

cfset var ds = arguments.datasource
cfset var rtn = 
cfset var childQry = 
cfset var level = arguments.levelCtr

cfif not structKeyExists(arguments, rtnQuery)
cfset rtn = queryNew(entryID, replyID, parentReplyID, level)
cfelse
cfset rtn = arguments.rtnQuery
/cfif

cfquery datasource=#ds# name=childQry
SELECT e.entryID,
r.replyID,
r.parentReplyID
FROM entries e LEFT OUTER JOIN
replies r ON e.entryID = r.entryID
WHERE e.entryID = cfqueryparam cfsqltype=CF_SQL_VARCHAR 
value=#arguments.entryID#
AND r.parentReplyID = cfquerparam 
cfsqltype=CF_SQL_VARCHAR value=#arguments.parentReplyID#
/cfquery

cfif childQry.recordCount
cfset level = level + 1
cfoutput query=childQry
cfset queryAddRow(rtn)
cfset querySetCell(rtn, entryID, entryID)
cfset querySetCell(rtn, replyID, replyID)
cfset querySetCell(rtn, parentReplyID, 
parentReplyID)
cfset querySetCell(rtn, level, level)
!--- now call this function recursively ---
cfset rtn = getChildren(
arguments.entryID, 
ds, 
replyID, 
duplicate(rtn), 
level
)
/cfoutput
/cfif

cfreturn rtn
/cffunction


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314872
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion to retrieve blog thread - help please

2008-11-05 Thread Christophe Maso
Thank you very much - this works beautifully! 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314889
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Recursion Output Help

2008-07-24 Thread Mark Leder
Hi All,

 

Been working on a recursion output for several days now without success.
Using a single category table with ID, Name, ParentID.  The nesting is up
to four layers deep.  Problem is, I want to tie the results set to documents
that have been posted, with the categoryID referencing the documentID.  And
only showing those collapsable tree elements that have documents (without
breaking the tree).

 

If anyone is open to assisting with display output, for fee, I'd greatly
appreciate it.  I don't care about what format the display takes (flash,
html, jquery, extjs, etc.) as long as it loads reasonably quickly.  Need to
do this pretty quickly, by mid-next week.   Can show you all the params via
webex.  Using CF8 and MS-SQL 2000. 

 

Contact me off list if your interested.  EDT Time zone.

 

Thanks,

 

Mark




~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309630
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion Output Help

2008-07-24 Thread Gerald Guido
Did you look at this:
http://nstree.riaforge.org/

On Thu, Jul 24, 2008 at 1:36 PM, Mark Leder [EMAIL PROTECTED] wrote:

 Hi All,



 Been working on a recursion output for several days now without success.
 Using a single category table with ID, Name, ParentID.  The nesting is up
 to four layers deep.  Problem is, I want to tie the results set to
 documents
 that have been posted, with the categoryID referencing the documentID.  And
 only showing those collapsable tree elements that have documents (without
 breaking the tree).



 If anyone is open to assisting with display output, for fee, I'd greatly
 appreciate it.  I don't care about what format the display takes (flash,
 html, jquery, extjs, etc.) as long as it loads reasonably quickly.  Need to
 do this pretty quickly, by mid-next week.   Can show you all the params via
 webex.  Using CF8 and MS-SQL 2000.



 Contact me off list if your interested.  EDT Time zone.



 Thanks,



 Mark




 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309642
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Recursion Output Help

2008-07-24 Thread Mark Leder
I did.  Couldn't figure out that logic + tree breaks when I only want to
return nodes and levels that correspond with documents/db listings on the
server.

-Original Message-
From: Gerald Guido [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 24, 2008 2:09 PM
To: CF-Talk
Subject: Re: Recursion Output Help

Did you look at this:
http://nstree.riaforge.org/

On Thu, Jul 24, 2008 at 1:36 PM, Mark Leder [EMAIL PROTECTED] wrote:

 Hi All,



 Been working on a recursion output for several days now without success.
 Using a single category table with ID, Name, ParentID.  The nesting is
up
 to four layers deep.  Problem is, I want to tie the results set to
 documents
 that have been posted, with the categoryID referencing the documentID.
And
 only showing those collapsable tree elements that have documents (without
 breaking the tree).



 If anyone is open to assisting with display output, for fee, I'd greatly
 appreciate it.  I don't care about what format the display takes (flash,
 html, jquery, extjs, etc.) as long as it loads reasonably quickly.  Need
to
 do this pretty quickly, by mid-next week.   Can show you all the params
via
 webex.  Using CF8 and MS-SQL 2000.



 Contact me off list if your interested.  EDT Time zone.



 Thanks,



 Mark




 



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309658
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion Output Help

2008-07-24 Thread Gerald Guido
I have a simple recursion example that I used a menu-ing system few years
back. Perhaps it may help.

http://mgt.pastebin.com/f4ff2f94f

On Thu, Jul 24, 2008 at 2:39 PM, Mark Leder [EMAIL PROTECTED] wrote:

 I did.  Couldn't figure out that logic + tree breaks when I only want to
 return nodes and levels that correspond with documents/db listings on the
 server.

 -Original Message-
 From: Gerald Guido [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 24, 2008 2:09 PM
 To: CF-Talk
 Subject: Re: Recursion Output Help

 Did you look at this:
 http://nstree.riaforge.org/

 On Thu, Jul 24, 2008 at 1:36 PM, Mark Leder [EMAIL PROTECTED] wrote:

  Hi All,
 
 
 
  Been working on a recursion output for several days now without success.
  Using a single category table with ID, Name, ParentID.  The nesting is
 up
  to four layers deep.  Problem is, I want to tie the results set to
  documents
  that have been posted, with the categoryID referencing the documentID.
 And
  only showing those collapsable tree elements that have documents (without
  breaking the tree).
 
 
 
  If anyone is open to assisting with display output, for fee, I'd greatly
  appreciate it.  I don't care about what format the display takes (flash,
  html, jquery, extjs, etc.) as long as it loads reasonably quickly.  Need
 to
  do this pretty quickly, by mid-next week.   Can show you all the params
 via
  webex.  Using CF8 and MS-SQL 2000.
 
 
 
  Contact me off list if your interested.  EDT Time zone.
 
 
 
  Thanks,
 
 
 
  Mark
 
 
 
 
 



 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:309674
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion problem

2007-09-21 Thread Claude Schneegans
 This little factorial function will show you that limit in a hurry

IMO, with a factorial function, you will hit a numeric overflow far 
before any limit in recursion level.

I have some recursive functions, got them loop to infinity while 
debugging, and like in most languages,
the only limit I got with CF was memory.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289086
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion problem

2007-09-21 Thread Claude Schneegans
 The recordset is not returning the heirarchy correctly however.

Please define not correctly

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289087
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion problem

2007-09-21 Thread Wil Genovese
run it and find out.  It is not a memory issue.


-- 
Wil Genovese

One man with courage makes a majority.
-Andrew Jackson

A fine is a tax for doing wrong. A tax is a fine for doing well. 



Claude Schneegans wrote:
  This little factorial function will show you that limit in a hurry

 IMO, with a factorial function, you will hit a numeric overflow far 
 before any limit in recursion level.

 I have some recursive functions, got them loop to infinity while 
 debugging, and like in most languages,
 the only limit I got with CF was memory.

   

~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289092
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion problem

2007-09-21 Thread Claude Schneegans
 run it and find out.  It is not a memory issue.

Of course it is not.
Recursing to a level of 1000 is not a problem.

As I said, with a factorial function, you will hit an overflow before 
any limit of recursion or any memory limit.
Can ou imagine how large is 1000! ?

At a certain point, you hit an infinite value, and this brakes the 
returntype=numeric condition.
This is what caused the error.

The limit is the size of a numeric value that CF can handle, nothing to 
do with a limit with recursive functions.

-- 
___
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.


~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289107
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion problem

2007-09-21 Thread Mike Little
this is a wondeful tutorial matt! thanks heaps for the link.

a lot is a little over my head, but i am getting there!!

mike

http://tutorial478.easycfm.com/ 

~|
Check out the new features and enhancements in the
latest product release - download the What's New PDF now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289172
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Recursion problem

2007-09-20 Thread Mike | NZSolutions Ltd
Hi guys,

I am attempting to create a limitless level category system.

This is what I have so far...

Calling page...

cfoutput
#application.category.display_categories(0)#
/cfoutput

Cfc...

cffunction name=get_categories output=false access=public
returntype=query
cfargument name=parent_id type=numeric required=no
cfargument name=cat_id type=numeric required=no

cfquery name=getCats datasource=#variables.dsn#
username=#variables.dbusername# password=#variables.dbpassword#
SELECT *
FROM categories
WHERE 1=1
cfif isDefined(arguments.cat_id)
AND cat_id = cfqueryparam
cfsqltype=cf_sql_integer value=#arguments.cat_id#
/cfif
cfif isDefined(arguments.parent_id)
AND parent_id = cfqueryparam
cfsqltype=cf_sql_integer value=#arguments.parent_id#
/cfif
/cfquery

cfreturn getCats /
/cffunction

cffunction name=display_categories output=true access=public
cfargument name=parent_id type=numeric required=yes
cfargument name=level type=numeric default=0

cfif arguments.level EQ 0
cfset variables.output = 
/cfif

cfset getCategories =
get_categories(parent_id=arguments.parent_id)

cfloop query=getCategories
cfset variables.output = variables.output 

table width='640' border='0'
cellspacing='0' cellpadding='5'
tr
td#getCategories.cat_title#/td
td width='50'div align='center'a
href='index.cfm?action=product_managerpage=editCatcat_id=#getCategories.ca
t_id#'Edit/a/div
/td
td width='50'div align='center'a
href='index.cfm?action=product_managerpage=categoriesstep=deletecat_id=#g
etCategories.cat_id#' onClick='GP_popupConfirmMsg('Are you sure you wish to
delete the category #getCategories.cat_title#? This action cannot be
undone.');return document.MM_returnValue'Delete/a/div
/td
/tr
/table
#arguments.level# ID:#getCategories.cat_id#

cfif isNumeric(getCategories.cat_id)
cfset variables.output =
variables.output 
display_categories(parent_id=getCategories.cat_id,level=arguments.level +
1)
/cfif
/cfloop

cfreturn variables.output /
/cffunction

The recordset is not returning the heirarchy correctly however. Can anyone
see what (big) mistakes I am making??

Thanks heaps.
mike



~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finderproductID=1522loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289060
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion problem

2007-09-20 Thread Wil Genovese
I'm not sure how many levels of recursion your trying to do, but with CF 
there is a limit to recursion.  This little factorial function will show 
you that limit in a hurry if you put in a large enough value.

cffunction name=factorial access=public returntype=numeric 
output=yes
cfargument name=end_value required=Yes type=numeric
cfif end_value lte 1
cfreturn 1
cfelse
Calling myself with #arguments.end_value-1#br
cfreturn end_value * Factorial(arguments.end_value-1)
/cfif
/cffunction


cfoutput#factorial(1000)#/cfoutput


Wil Genovese

One man with courage makes a majority.
-Andrew Jackson

A fine is a tax for doing wrong. A tax is a fine for doing well. 



Mike | NZSolutions Ltd wrote:
 Hi guys,

 I am attempting to create a limitless level category system.

 This is what I have so far...

 Calling page...

 cfoutput
 #application.category.display_categories(0)#
 /cfoutput

 Cfc...

 cffunction name=get_categories output=false access=public
 returntype=query
   cfargument name=parent_id type=numeric required=no
   cfargument name=cat_id type=numeric required=no
   
   cfquery name=getCats datasource=#variables.dsn#
 username=#variables.dbusername# password=#variables.dbpassword#
   SELECT *
   FROM categories
   WHERE 1=1
   cfif isDefined(arguments.cat_id)
   AND cat_id = cfqueryparam
 cfsqltype=cf_sql_integer value=#arguments.cat_id#
   /cfif
   cfif isDefined(arguments.parent_id)
   AND parent_id = cfqueryparam
 cfsqltype=cf_sql_integer value=#arguments.parent_id#
   /cfif
   /cfquery
   
   cfreturn getCats /
   /cffunction

 cffunction name=display_categories output=true access=public
   cfargument name=parent_id type=numeric required=yes
   cfargument name=level type=numeric default=0
   
   cfif arguments.level EQ 0
 cfset variables.output = 
 /cfif
   
   cfset getCategories =
 get_categories(parent_id=arguments.parent_id)
   
   cfloop query=getCategories
   cfset variables.output = variables.output 
 
   table width='640' border='0'
 cellspacing='0' cellpadding='5'
   tr
   td#getCategories.cat_title#/td
   td width='50'div align='center'a
 href='index.cfm?action=product_managerpage=editCatcat_id=#getCategories.ca
 t_id#'Edit/a/div
   /td
   td width='50'div align='center'a
 href='index.cfm?action=product_managerpage=categoriesstep=deletecat_id=#g
 etCategories.cat_id#' onClick='GP_popupConfirmMsg('Are you sure you wish to
 delete the category #getCategories.cat_title#? This action cannot be
 undone.');return document.MM_returnValue'Delete/a/div
   /td
   /tr
   /table
   #arguments.level# ID:#getCategories.cat_id#
   
   cfif isNumeric(getCategories.cat_id)
   cfset variables.output =
 variables.output 
 display_categories(parent_id=getCategories.cat_id,level=arguments.level +
 1)
   /cfif
   /cfloop
   
   cfreturn variables.output /
   /cffunction

 The recordset is not returning the heirarchy correctly however. Can anyone
 see what (big) mistakes I am making??

 Thanks heaps.
 mike



 

~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289063
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion problem

2007-09-20 Thread Mike Little
i will only ever be going 2-3 levels deep at this stage.

I'm not sure how many levels of recursion your trying to do, but with CF 
there is a limit to recursion.  This little factorial function will show 
you that limit in a hurry if you put in a large enough value.

cffunction name=factorial access=public returntype=numeric 
output=yes
cfargument name=end_value required=Yes type=numeric
cfif end_value lte 1
cfreturn 1
cfelse
Calling myself with #arguments.end_value-1#br
cfreturn end_value * Factorial(arguments.end_value-1)
/cfif
/cffunction


cfoutput#factorial(1000)#/cfoutput


Wil Genovese

One man with courage makes a majority.
-Andrew Jackson

A fine is a tax for doing wrong. A tax is a fine for doing well. 



Mike | NZSolutions Ltd wrote:
 

~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289065
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Recursion problem

2007-09-20 Thread James Holmes
You can get the whole structure on one query:

http://www.oreilly.com/catalog/sqlpr/chapter/ch01.pdf

On 9/21/07, Mike Little [EMAIL PROTECTED] wrote:
 i will only ever be going 2-3 levels deep at this stage.

 I'm not sure how many levels of recursion your trying to do, but with CF
 there is a limit to recursion.  This little factorial function will show
 you that limit in a hurry if you put in a large enough value.
 
 cffunction name=factorial access=public returntype=numeric
 output=yes
 cfargument name=end_value required=Yes type=numeric
 cfif end_value lte 1
 cfreturn 1
 cfelse
 Calling myself with #arguments.end_value-1#br
 cfreturn end_value * Factorial(arguments.end_value-1)
 /cfif
 /cffunction
 
 
 cfoutput#factorial(1000)#/cfoutput
 
 
 Wil Genovese
 
 One man with courage makes a majority.
 -Andrew Jackson
 
 A fine is a tax for doing wrong. A tax is a fine for doing well.
 
 
 
 Mike | NZSolutions Ltd wrote:
 

 

~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289066
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion problem

2007-09-20 Thread Matt Quackenbush
http://tutorial478.easycfm.com/


~|
Check out the new features and enhancements in the
latest product release - download the What's New PDF now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289067
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: OT: Open DNS Server / Recursion

2006-10-30 Thread Tom Chiverton
On Thursday 26 October 2006 19:14, Eric Haskins wrote:
 Dont block DNS requests at the firewall. Your customers wont be happy when
 their sites dont resolve :)

90% of the time it's cheaper and easier to have someone else run the DNS.

-- 
Tom Chiverton
Helping to autoschediastically architect exceptional market-growth



This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at St 
James's Court Brown Street Manchester M2 2JF.  A list of members is available 
for inspection at the registered office. Any reference to a partner in relation 
to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law 
Society.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 8008.

For more information about Halliwells LLP visit www.halliwells.com.


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258418
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Open DNS Server / Recursion

2006-10-27 Thread Jenny Gavin-Wear
The problem is that with Recursion enabled on a DNS server hosting domain is
it allows IP forging for spammers. (From what I have read.) I have some
pillock spammer forging my IP through this method.  I have been told by my
hosting company that I need to sort this out.

With recursion turned off it means the mail server won't work as it won't be
able to look up non-local domains. So, I need to be able to restrict the
facility of recursive lookups to the local IPs.  I can't see any way to do
that.


-Original Message-
From: Russ [mailto:[EMAIL PROTECTED]
Sent: 26 October 2006 19:17
To: CF-Talk
Subject: RE: Open DNS Server / Recursion


Easy... don't disable recursive lookups.

Without recursive lookups, your DNS server will only respond to queries
about things that it knows... i.e. the dns entries hosted on your server.

In order for it to resolve domains that it knows nothing about, it must go
and do a recursive lookup using other dns servers.

Russ

 -Original Message-
 From: Jenny Gavin-Wear [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 26, 2006 8:44 AM
 To: CF-Talk
 Subject: OT: Open DNS Server / Recursion

 Totally off topic.

 I run DNS servers for a number of domains and also mail servers for those
 domains.

 I have a problem in that when I disable Recursive look ups the DNS servers
 then fail to answer DNS queries from the local IP addresses.

 Any ideas anyone please?

 Jenny

 Jennifer Gavin-Wear
 Fast Track Online
 Tel: 01262 602013
 http://www.fasttrackonline.co.uk/


 --
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.408 / Virus Database: 268.13.11/497 - Release Date:
 25/10/2006







~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258222
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Open DNS Server / Recursion

2006-10-27 Thread Eric Haskins
Run a second internal recursive DNS server for your local users. Then set
your DNS Server for your domains without recursion.

Eric Haskins
Web Systems Developer
Rooms To Go


On 10/27/06, Jenny Gavin-Wear [EMAIL PROTECTED] wrote:

 The problem is that with Recursion enabled on a DNS server hosting domain
 is
 it allows IP forging for spammers. (From what I have read.) I have some
 pillock spammer forging my IP through this method.  I have been told by my
 hosting company that I need to sort this out.

 With recursion turned off it means the mail server won't work as it won't
 be
 able to look up non-local domains. So, I need to be able to restrict the
 facility of recursive lookups to the local IPs.  I can't see any way to do
 that.


 -Original Message-
 From: Russ [mailto:[EMAIL PROTECTED]
 Sent: 26 October 2006 19:17
 To: CF-Talk
 Subject: RE: Open DNS Server / Recursion


 Easy... don't disable recursive lookups.

 Without recursive lookups, your DNS server will only respond to queries
 about things that it knows... i.e. the dns entries hosted on your server.

 In order for it to resolve domains that it knows nothing about, it must go
 and do a recursive lookup using other dns servers.

 Russ

  -Original Message-
  From: Jenny Gavin-Wear [mailto:[EMAIL PROTECTED]
  Sent: Thursday, October 26, 2006 8:44 AM
  To: CF-Talk
  Subject: OT: Open DNS Server / Recursion
 
  Totally off topic.
 
  I run DNS servers for a number of domains and also mail servers for
 those
  domains.
 
  I have a problem in that when I disable Recursive look ups the DNS
 servers
  then fail to answer DNS queries from the local IP addresses.
 
  Any ideas anyone please?
 
  Jenny
 
  Jennifer Gavin-Wear
  Fast Track Online
  Tel: 01262 602013
  http://www.fasttrackonline.co.uk/
 
 
  --
  No virus found in this outgoing message.
  Checked by AVG Free Edition.
  Version: 7.1.408 / Virus Database: 268.13.11/497 - Release Date:
  25/10/2006
 
 
 
 



 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258260
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Open DNS Server / Recursion

2006-10-27 Thread Dennis Powers
 I have a problem in that when I disable Recursive look 
 ups the DNS servers then fail to answer DNS queries 
 from the local IP addresses.

In BIND you can set the bind.conf file to only allow certain IP address to
be able to initiate a recursive query.

The directive is in the options section:

options {
  directory c:\bind\etc;
  // version statement for security to avoid hacking known weaknesses   
  version not disclosed;
  // disables all zone transfer requests except for local network
  allow-transfer{12.199.124.0/23;};
  // Allow anyone to query
  // only allow the local net to issue recursive queries
  allow-query {any;};
  allow-recursion {12.199.124.0/23;};
};



Best Regards,

Dennis Powers
UXB Internet - A website design and Hosting Company
690 Wolcott Road
P.O. Box 6029
Wolcott, CT  06716
Tel: (203)879-2844
http://www.uxbinternet.com/
http://www.uxb.net/ 




~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258282
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


OT: Open DNS Server / Recursion

2006-10-26 Thread Jenny Gavin-Wear
Totally off topic.

I run DNS servers for a number of domains and also mail servers for those
domains.

I have a problem in that when I disable Recursive look ups the DNS servers
then fail to answer DNS queries from the local IP addresses.

Any ideas anyone please?

Jenny

Jennifer Gavin-Wear
Fast Track Online
Tel: 01262 602013
http://www.fasttrackonline.co.uk/


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.11/497 - Release Date: 25/10/2006



~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258093
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: OT: Open DNS Server / Recursion

2006-10-26 Thread Tom Chiverton
On Thursday 26 October 2006 13:43, Jenny Gavin-Wear wrote:
 I have a problem in that when I disable Recursive look ups the DNS servers
 then fail to answer DNS queries from the local IP addresses.
 Any ideas anyone please?

Don't turn recursive lookups off :-)
They are what makes your DNS server go off and ask other ones, so when you 
turn if off *bam* no resolved hosts apart whatever the server itself knows 
about.
A more normal solution is to block incoming DNS requests at the firewall.

-- 
Tom Chiverton
Helping to competently architect web-enabled initiatives



This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at St 
James's Court Brown Street Manchester M2 2JF.  A list of members is available 
for inspection at the registered office. Any reference to a partner in relation 
to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law 
Society.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 8008.

For more information about Halliwells LLP visit www.halliwells.com.


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258100
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: OT: Open DNS Server / Recursion

2006-10-26 Thread Eric Haskins
Dont block DNS requests at the firewall. Your customers wont be happy when
their sites dont resolve :)

We have recursion turned off on our DotCom DNS because we only host 6
Domains. All our coporate users use a Recursing DNS server to do their
surfing. So if it is for both Surfing and Hosting then you need recursive
lookups. If the server will only answer requests for your domains then turn
off recursive lookups to save some traffic.  In either case dont block port
53 at the firewall or by bye websites :)

Eric Haskins
Web Systems Developer
Rooms To Go



On 10/26/06, Tom Chiverton [EMAIL PROTECTED] wrote:

 On Thursday 26 October 2006 13:43, Jenny Gavin-Wear wrote:
  I have a problem in that when I disable Recursive look ups the DNS
 servers
  then fail to answer DNS queries from the local IP addresses.
  Any ideas anyone please?

 Don't turn recursive lookups off :-)
 They are what makes your DNS server go off and ask other ones, so when you
 turn if off *bam* no resolved hosts apart whatever the server itself knows
 about.
 A more normal solution is to block incoming DNS requests at the firewall.

 --
 Tom Chiverton
 Helping to competently architect web-enabled initiatives

 

 This email is sent for and on behalf of Halliwells LLP.

 Halliwells LLP is a limited liability partnership registered in England
 and Wales under registered number OC307980 whose registered office address
 is at St James's Court Brown Street Manchester M2 2JF.  A list of members is
 available for inspection at the registered office. Any reference to a
 partner in relation to Halliwells LLP means a member of Halliwells LLP.
 Regulated by the Law Society.

 CONFIDENTIALITY

 This email is intended only for the use of the addressee named above and
 may be confidential or legally privileged.  If you are not the addressee you
 must not read it and must not use any information contained in nor copy it
 nor inform any person other than Halliwells LLP or the addressee of its
 existence or contents.  If you have received this email in error please
 delete it and notify Halliwells LLP IT Department on 0870 365 8008.

 For more information about Halliwells LLP visit www.halliwells.com.


 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258147
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Open DNS Server / Recursion

2006-10-26 Thread Russ
Easy... don't disable recursive lookups.  

Without recursive lookups, your DNS server will only respond to queries
about things that it knows... i.e. the dns entries hosted on your server.   

In order for it to resolve domains that it knows nothing about, it must go
and do a recursive lookup using other dns servers. 

Russ

 -Original Message-
 From: Jenny Gavin-Wear [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 26, 2006 8:44 AM
 To: CF-Talk
 Subject: OT: Open DNS Server / Recursion
 
 Totally off topic.
 
 I run DNS servers for a number of domains and also mail servers for those
 domains.
 
 I have a problem in that when I disable Recursive look ups the DNS servers
 then fail to answer DNS queries from the local IP addresses.
 
 Any ideas anyone please?
 
 Jenny
 
 Jennifer Gavin-Wear
 Fast Track Online
 Tel: 01262 602013
 http://www.fasttrackonline.co.uk/
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.408 / Virus Database: 268.13.11/497 - Release Date:
 25/10/2006
 
 
 
 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:258148
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Recursion anyone?

2005-10-27 Thread Stephen Whiteley
Thanks David, I get that:)

Steve

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222402
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Hi

I keep returning to this problem in order to build an infinite DHTML menu (a 
task which has now become a quest and a matter of honour). Does anyone know how 
to recurse through an adjacency list model table, of the following setup

ID CategoryName ParentItemID

Also, I hear you can use CFTREE format=xml or format=object and then use 
that to make a DHTML menu? anyone have any experience

Muchos Thank You's

Steve

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:79
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Thomas Chiverton
On Wednesday 26 October 2005 11:15, Stephen Whiteley wrote:
 know how to recurse through an adjacency list model table, of the following
 setup

 ID CategoryName ParentItemID

topLevel=getNodesWithNoParent()
foreach thisNode in topLevel{
print thisNode
getChildren(thisNode)
}

function getChildren(aNode){
childList=getChildrenOf(aNode);
foreach aNode on childList{
print aNode
getChildren(aNode)
}
}

getNodesWithNoParent() is easy.

-- 

Tom Chiverton 
Advanced ColdFusion Programmer

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:83
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
There are loads and loads of DHTML menus out there, e.g.
http://www.dynamicdrive.com/dynamicindex1/hvmenu/

with the actual menu code taken care of, all you have to do is recurse over
your database and write out the menu items.

last time i checked, cftree outputs a java applet, not javascript.

do you not know how to recurse?

heres some pseudo code

variables.inst.menuqry = getAllCategories();

function buildmenu(currentid){
var i=0;
for(i=1; i lte variables.inst.menuqry.recorcount; i=i+1){
if(variables.inst.menuqry.parent_id[i] eq arguments.currentID)
writeoutput(your javascript);
buildmenu(variables.inst.menuqry.id[i]);
}
}
}

buildmenu(yourrootid);


-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 11:15
To: CF-Talk
Subject: Recursion anyone?


Hi

I keep returning to this problem in order to build an infinite DHTML menu (a
task which has now become a quest and a matter of honour). Does anyone know
how to recurse through an adjacency list model table, of the following setup

ID CategoryName ParentItemID

Also, I hear you can use CFTREE format=xml or format=object and then use
that to make a DHTML menu? anyone have any experience

Muchos Thank You's

Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:84
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread James Holmes
Depending on your DB you may be able to do the recursion there rather
than in the CF or JS code:

http://www.oreilly.com/catalog/sqlpr/chapter/ch01.pdf

On 10/26/05, Stephen Whiteley [EMAIL PROTECTED] wrote:
 Hi

 I keep returning to this problem in order to build an infinite DHTML menu (a 
 task which has now become a quest and a matter of honour). Does anyone know 
 how to recurse through an adjacency list model table, of the following setup

 ID CategoryName ParentItemID

 Also, I hear you can use CFTREE format=xml or format=object and then use 
 that to make a DHTML menu? anyone have any experience

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:85
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Snake
Why not use one of the nice DHTML menus that already exists.

I have built a tag that creates an DHTML explorer tree, and all I do is
query my category's, putitng them in the correct order, then recursively
loop over that query to check for child items of the current node.

--
Russ

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED] 
Sent: 26 October 2005 11:15
To: CF-Talk
Subject: Recursion anyone?

Hi

I keep returning to this problem in order to build an infinite DHTML menu (a
task which has now become a quest and a matter of honour). Does anyone know
how to recurse through an adjacency list model table, of the following setup

ID CategoryName ParentItemID

Also, I hear you can use CFTREE format=xml or format=object and then use
that to make a DHTML menu? anyone have any experience

Muchos Thank You's

Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:86
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Hi

Yes the problem is the recursion can't get my head round it, never used 
CFSCRIPT before being a bit of a newbie.

Not trying to build a DHTML menu from scratch and would use an off the shelf 
one.

CFTREE in CFMX 7 will output xml or a structure depending on format= used.

I'll keep playing with the code provided thanks, but if anyone can expand for a 
dummy, much appreciated

Steve

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:87
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
OK, this is my database setup

ItemID,ParentItemID,AdCategoryName

What I want to be able to do is output something like this (before I go to the 
DHTML menu stage, walk before I can run)

Accommodation
Self Catering
Farmhouse
Rustic Farmhouse
Activities
Walking
Walking Routes
 Walking Shops

etc. etc...

I'm sure once a get the hang of it I'll be ok but any help much appreciated

Thanks

Steve


~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:89
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Andy Matthews
Stephen...

Here's some code for you. Create the table first:

CREATE TABLE links (
link_id smallint(5) unsigned NOT NULL auto_increment,
link_childof smallint(5) unsigned NOT NULL default '0',
link_name varchar(100) NOT NULL default '',
) TYPE=MyISAM;

Then here's the SQL to pull 3 levels of links.

cfquery name=getLinks dataSource=#Application.DSN#
dbType=#Application.DBType# username=#Application.username#
password=#Application.password#
SELECT
top.link_id AS top_id, top.link_name AS top_name,
mid.link_id AS mid_id, mid.link_name AS mid_name,
sub.link_id AS sub_id, sub.link_name AS sub_name
FROM links top
LEFT OUTER JOIN links mid
ON mid.link_childof = top.link_id
LEFT OUTER JOIN links sub
ON sub.link_childof = mid.link_id
WHERE top.link_childof = 0
GROUP BY top_name, mid_name, sub_name
ORDER BY top_name, mid_name, sub_name
/cfquery

I use this method all the time and it works beautifully.

!//--
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--//-

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 26, 2005 6:11 AM
To: CF-Talk
Subject: Re: Recursion anyone?


Hi

Yes the problem is the recursion can't get my head round it, never used
CFSCRIPT before being a bit of a newbie.

Not trying to build a DHTML menu from scratch and would use an off the shelf
one.

CFTREE in CFMX 7 will output xml or a structure depending on format= used.

I'll keep playing with the code provided thanks, but if anyone can expand
for a dummy, much appreciated

Steve



~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:94
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Kerry

I'm trying to get you code to work but will be making a real hash of it, I 
wonder if you take a look at this, I think getting the query in is the problem.

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript

variables.inst.menuqry = getAllCategories();

function buildmenu(currentid){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(variables.menuqry.adcategoryname);
buildmenu(variables.inst.menuqry.itemid[i]);
  }
  }

/cfscript

cfset returnValue=buildmenu(10)


cfoutput#returnvalue#/cfoutput

thanks


Steve

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:95
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
1) in my original code, getallcategories is a function, not a query.
change to: variables.inst.menuqry = getAllCategories;

2) note that the buildmenu function does not return anything, so this:

cfset returnValue=buildmenu(10)
Is going to give you null.


3) writeoutput(variables.menuqry.adcategoryname);

This is just going to give you one big indecipherable string.

cfscript
function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

!---
these lines dont make sense
cfset returnValue=buildmenu(10)


cfoutput#returnvalue#/cfoutput
---

3.2) variables.menuqry.adcategoryname
This will always give you the first record's categoryname.
when doing a for() loop, you _must_ use the counter
variables.menuqry.adcategoryname[i]


Good luck!



-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 14:51
To: CF-Talk
Subject: Re: Recursion anyone?


Kerry

I'm trying to get you code to work but will be making a real hash of it, I
wonder if you take a look at this, I think getting the query in is the
problem.

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript

variables.inst.menuqry = getAllCategories();

function buildmenu(currentid){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(variables.menuqry.adcategoryname);
buildmenu(variables.inst.menuqry.itemid[i]);
  }
  }

/cfscript

cfset returnValue=buildmenu(10)


cfoutput#returnvalue#/cfoutput

thanks


Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222302
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot 
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following error.

Context validation error for tag cfscript.  
The start tag must have a matching end tag. An explicit end tag can be provided 
by adding /cfscript. If the body of the tag is empty you can use the shortcut 
cfscript .../. 


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryname[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222308
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Andy Matthews
You're missing a semicolon at the end of the last expression in the cfscript
tag. This:
buildmenu(10,0)

should be this:
buildmenu(10,0);

!//--
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--//-

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 26, 2005 9:30 AM
To: CF-Talk
Subject: Re: Recursion anyone?


Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../.


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222310
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Emmet McGovern
Here's a use of treeview.nets treeview with recursion.
http://fullcitymedia.com/apps/treeview 

You can download the code here.
http://fullcitymedia.com/apps/treeview/treeview.zip 

Take a look, might be similar to what you're looking for.

Emmet

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 26, 2005 10:30 AM
To: CF-Talk
Subject: Re: Recursion anyone?

Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.  
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../. 


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222323
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Thanks, missed that

Still throwing an error though

Variable PARENTITEMID is undefined.  
 
  
The error occurred in C:\Inetpub\wwwroot\bigtripper\recurse\testfunction.cfm: 
line 11
 
9 : function buildmenu(currentid,depth){
10 :   var i=0;
11 :   for(i=1; i lte parentitemid.menuqry.recordcount; i=i+1){
12 :   if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)

 
The code is below:

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recordcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryname[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(1,0);
/cfscript

Thanks

Steve

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222324
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
11 :   for(i=1; i lte parentitemid.menuqry.recordcount; i=i+1){

My original post contains:
variables.inst.menuqry.recordcount

You changed it to:
parentitemid.menuqry.recordcount

Change it back.

p.s.
dude, I dont mind helping with the overall how do i do this, but asking me
to debug simple errors in your code is pushing it.


-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 15:52
To: CF-Talk
Subject: Re: Recursion anyone?


Thanks, missed that

Still throwing an error though

Variable PARENTITEMID is undefined.


The error occurred in
C:\Inetpub\wwwroot\bigtripper\recurse\testfunction.cfm: line 11

9 : function buildmenu(currentid,depth){
10 :   var i=0;
11 :   for(i=1; i lte parentitemid.menuqry.recordcount; i=i+1){
12 :   if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)


The code is below:

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recordcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(1,0);
/cfscript

Thanks

Steve



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222329
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
buildmenu(10,0);
/cfscript

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 15:30
To: CF-Talk
Subject: Re: Recursion anyone?


Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../.


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve



~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222342
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Thomas Chiverton
On Wednesday 26 October 2005 16:03, Kerry wrote:
 dude, I dont mind helping with the overall how do i do this, but asking
 me to debug simple errors in your code is pushing it.

This is why most of the time I will only post pseudo-code, unless there is 
some important point the code needs to get across.

I'm all for offering 'how to' and the odd bit of skeleton code, but I don't 
develop ColdFusion code for free :-)
Although, OTOH the list does need to cater for all ability types, and 
sometimes that does mean a fully worked up example, I suppose.

-- 

Tom Chiverton 
Advanced ColdFusion Programmer

~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222351
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
Just had a read of the code, it does 2 queries for every parent in the
database?
Did I read that correctly?

-Original Message-
From: Emmet McGovern [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 15:49
To: CF-Talk
Subject: RE: Recursion anyone?


Here's a use of treeview.nets treeview with recursion.
http://fullcitymedia.com/apps/treeview

You can download the code here.
http://fullcitymedia.com/apps/treeview/treeview.zip

Take a look, might be similar to what you're looking for.

Emmet

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 26, 2005 10:30 AM
To: CF-Talk
Subject: Re: Recursion anyone?

Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../.


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve





~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222355
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Kerry
make that 1 query for every parent, + 1 query for each child of each parent.

-Original Message-
From: Emmet McGovern [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 15:49
To: CF-Talk
Subject: RE: Recursion anyone?


Here's a use of treeview.nets treeview with recursion.
http://fullcitymedia.com/apps/treeview

You can download the code here.
http://fullcitymedia.com/apps/treeview/treeview.zip

Take a look, might be similar to what you're looking for.

Emmet

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 26, 2005 10:30 AM
To: CF-Talk
Subject: Re: Recursion anyone?

Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../.


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve





~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222357
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recursion anyone?

2005-10-26 Thread Emmet McGovern
You're correct.  It simply reincludes itself till it no longer finds a
dependency.  I know there are more efficient ways to do it but it works for
this example.

This discussion forces me to revisit.  One day I'll purty it up a bit more
and put it up for download somewhere.  Haven't looked at it for some time.

Emmet



-Original Message-
From: Kerry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 26, 2005 12:23 PM
To: CF-Talk
Subject: RE: Recursion anyone?

make that 1 query for every parent, + 1 query for each child of each parent.

-Original Message-
From: Emmet McGovern [mailto:[EMAIL PROTECTED]
Sent: 26 October 2005 15:49
To: CF-Talk
Subject: RE: Recursion anyone?


Here's a use of treeview.nets treeview with recursion.
http://fullcitymedia.com/apps/treeview

You can download the code here.
http://fullcitymedia.com/apps/treeview/treeview.zip

Take a look, might be similar to what you're looking for.

Emmet

-Original Message-
From: Stephen Whiteley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 26, 2005 10:30 AM
To: CF-Talk
Subject: Re: Recursion anyone?

Thanks Kerry

I'm starting to understand, got no experience of cfscript but it seems a lot
like actionscript.

Unfortunately I've tried to run the code and I'm getting the following
error.

Context validation error for tag cfscript.
The start tag must have a matching end tag. An explicit end tag can be
provided by adding /cfscript. If the body of the tag is empty you can use
the shortcut cfscript .../.


This is the exact code

cfquery datasource=#DSN# name=getAllCategories
SELECT itemid,parentitemid,adcategoryname FROM tblAdvertTypes
/cfquery


cfscript
variables.inst.menuqry = getAllCategories;

function buildmenu(currentid,depth){
  var i=0;
  for(i=1; i lte parentitemid.menuqry.recorcount; i=i+1){
  if(variables.inst.menuqry.parentitemid[i] eq arguments.currentID)
writeoutput(repeatstring(,arguments.depth)variables.menuqry.adcategoryna
me[i]br);
buildmenu(variables.inst.menuqry.itemid[i],arguments.depth+1);
  }
  }

buildmenu(10,0)
/cfscript

Steve







~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222361
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread Stephen Whiteley
Hi

Thanks everyone, there's lots of different approaches here which I'll look at 
over time. Brain got tired in the end! I just thought that with the new CFTREE 
format options i.e. xml and object, that there could be a quick (and easy) way 
to do DHTML menus.

But I've learnt quite a bit, sorry if I hacked anyone off - the ease of basic 
Coldfusion means that not everyone who uses it is a full-on programmer with a 
computer-science degree. So difficult to debug code when you're not 100% sure 
what it does!

I eventually found an off the peg DHTML and recursion solution here 
http://www.xtreeme.com/dhtml/dynamic-creation/ which although not directly 
supporting coldfusion does work really well and solves my immediate problem.

Thanks again

Steve

~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222369
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recursion anyone?

2005-10-26 Thread David Livingston
An easy way to do recursion in cf is to use a custom tag. One of the  
things you will have to do is have your top level be set to a parent  
id that wont get used in any levels below it. I like to set the top  
level to zero or one.
The first time you call your custom tag you just pass the top level  
id you have chosen in as the first id. Then inside of that call the  
tag again passing the parentid. The code is untested but should give  
you a general idea.

Dave

cf_getmenu ParentItemID=1 level=1


The code would go something like this:

cfset level=#Attributes.level# + 1

cfquery datasource=#Application.dsn# name=getCats
 SELECT ID, CategoryName, ParentItemID
 FROM CategoryTable
 WHERE ParentItemID = #Attributes.ParentItemID#
/cfquery

cfoutput query=getCats
cfloop from=1 to=#Attributes.level#-/cfloop#CategoryName#
/cfoutput

cf_getmenu ParentItemID=#getCats.ParentItemID# level=#level#





On Oct 26, 2005, at 5:15 AM, Stephen Whiteley wrote:

 Hi

 I keep returning to this problem in order to build an infinite  
 DHTML menu (a task which has now become a quest and a matter of  
 honour). Does anyone know how to recurse through an adjacency list  
 model table, of the following setup

 ID CategoryName ParentItemID

 Also, I hear you can use CFTREE format=xml or format=object and  
 then use that to make a DHTML menu? anyone have any experience

 Muchos Thank You's

 Steve

 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222390
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
I've created a custom tag that recurses over a database to create a breadcrumb trail.The problem I'm encountering is I would really like to be able to pull a list from that tag that it can then be easily manipulated.Below is the custom tag code:

cfquery name=checkParent datasource=#request.siteDSN#
SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
WHERE keywords.keyword = '#attributes.child#'
/cfquery

cfloop query=checkParent

cfquery name=checkNextParent datasource=#request.siteDSN#
SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
WHERE keywords.keyword = '#checkParent.parentName#'
/cfquery

cfoutput

cfif checkNextParent.recordcount NEQ 0
cf_breadcrumbs child=#checkParent.parentName# breadcrumbs=  a href=''#checkParent.ParentTitle#/asiteDomain=#attributes.siteDomain#
/cfif

/cfoutput

/cfloop

cfoutput
#attributes.breadcrumbs#
/cfoutput

Currently the breadcrumbs display directly from the custom tag which works relatively well.Except there are instances when I would really like to have the data placed into a list.Any ideas how I could accomplish this?Any help would be greatly appreciated.

--Anne
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread John Beynon
valuelist() perhaps?

jb.

On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:
 I've created a custom tag that recurses over a database to create a breadcrumb trail.The problem I'm encountering is I would really like to be able to pull a list from that tag that it can then be easily manipulated.Below is the custom tag code:
 
 cfquery name=checkParent datasource=#request.siteDSN#
 SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
 FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
 WHERE keywords.keyword = '#attributes.child#'
 /cfquery
 
 cfloop query=checkParent
 
 cfquery name=checkNextParent datasource=#request.siteDSN#
 SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
 FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
 WHERE keywords.keyword = '#checkParent.parentName#'
 /cfquery
 
 cfoutput
 
 cfif checkNextParent.recordcount NEQ 0
 cf_breadcrumbs child=#checkParent.parentName# breadcrumbs=  a href=''#checkParent.ParentTitle#/asiteDomain=#attributes.siteDomain#
 /cfif
 
 /cfoutput
 
 /cfloop
 
 cfoutput
 #attributes.breadcrumbs#
 /cfoutput
 
 Currently the breadcrumbs display directly from the custom tag which works relatively well.Except there are instances when I would really like to have the data placed into a list.Any ideas how I could accomplish this?Any help would be greatly appreciated.
 
 --Anne
 

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
I don't think that will work in a recursion judging by what I've read about it.It seems it just takes data from a query column and creates a list out of it. But, that's assuming all of the data needed for the list is there on the first query.Since I'm dealing with a recursion, the query will obtain only one record per recurse of the tag.Granted, I may not fully understand how this tag could be used in my case so if I'm misunderstanding it, please enlighten me. One other issue is that I also need to be able to attain the list from outside the custom tag which may or may not put another snag into this problem.

Thanks,
--Anne

valuelist() perhaps?

jb.

On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Joe Rinehart
Hi Anne,

In your custom tag, you can look at the base tag list with
getBaseTagList() and see if it is its own first base tag.If not,
create a structure called ancestorData, and give it a member called
ancestorList.If it is its own base tag, create a reference to the
structure using ancestorData =
getBaseTagData(cf_breadcrumbs).ancestorData.At the end of your
breadcrumbs tag, pass the structure back to the current page using the
caller scope.

On a side note, this system could be very resource intensive.You may
want to look at ways to have your navigation table track its own
hierarchy, having a column that tracks what generation a child is, and
what its root parent ID is.That way, you can query an entire
breadcrumb in one query by asking for all children of a root parent ID
ordered by their generation.

Disclaimer:There are also many other ways to implement this that are
even less intensive, but require more development that I can't go into
right now because my dev server just came back up.

Cheers,

Joe

- Original Message -
From: Anne Girardeau [EMAIL PROTECTED]
Date: Tue, 24 Aug 2004 10:48:03 -0400
Subject: Re: Creating a List from a Recursion
To: CF-Talk [EMAIL PROTECTED]

I don't think that will work in a recursion judging by what I've read
about it.It seems it just takes data from a query column and creates
a list out of it. But, that's assuming all of the data needed for the
list is there on the first query.Since I'm dealing with a recursion,
the query will obtain only one record per recurse of the tag. 
Granted, I may not fully understand how this tag could be used in my
case so if I'm misunderstanding it, please enlighten me. One other
issue is that I also need to be able to attain the list from outside
the custom tag which may or may not put another snag into this
problem.

 Thanks,
 --Anne

valuelist() perhaps?
 
 jb.
 
 On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau
[EMAIL PROTECTED] wrote:
 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
Hey Joe,

Thanks for your input.Actually I figured something out using session variables and it works amazingly well. The performance of it also isn't too terrible since the most the script should ever recurse would be 5 or 6 times, if that.

I am, however, intrigued by your comment about having the database track its own hierarchy.I tried creating new columns for generation and parent root but got stuck when I was trying to get the path for a 3rd generation crumb with several 2nd generation crumbs that shared the same root, if that makes any sense.In other words, I could get the first and last breadcrumbs without problems but getting the second was a bit difficult without something to tell the system which second generation crumb to use.

The other option you suggested I did play around with but was never able to totally figure it out.I'm assuming it's intended to be utilized in a CF script and I don't have too much experience with CF scripting.

Thanks for your help,
--Anne

Hi Anne,

In your custom tag, you can look at the base tag list with
getBaseTagList() and see if it is its own first base tag.If not,
create a structure called ancestorData, and give it a member called
ancestorList.If it is its own base tag, create a reference to the
structure using ancestorData =
getBaseTagData(cf_breadcrumbs).ancestorData.At the end of your
breadcrumbs tag, pass the structure back to the current page using the
caller scope.

On a side note, this system could be very resource intensive.You may
want to look at ways to have your navigation table track its own
hierarchy, having a column that tracks what generation a child is, and
what its root parent ID is.That way, you can query an entire
breadcrumb in one query by asking for all children of a root parent ID
ordered by their generation.

Disclaimer:There are also many other ways to implement this that are
even less intensive, but require more development that I can't go into
right now because my dev server just came back up.

Cheers,

Joe
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Barney Boisvert
I'd recommend using the request scope, rather than the session scope. 
A breadcrumb display is not bound to a user session in any way, it's
strictly related to the current request.

Joe's suggestion to use the custom tag framework that CF provides is
superior even to that, because it allows multiple invocations of the
tag on a single request to remain totally independant, but that's
probably not much of an issue with breadcrumb generation.

cheers,
barneyb

On Tue, 24 Aug 2004 17:24:01 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:
 Hey Joe,
 
 Thanks for your input.Actually I figured something out using session variables and it works amazingly well. The performance of it also isn't too terrible since the most the script should ever recurse would be 5 or 6 times, if that.
 
 I am, however, intrigued by your comment about having the database track its own hierarchy.I tried creating new columns for generation and parent root but got stuck when I was trying to get the path for a 3rd generation crumb with several 2nd generation crumbs that shared the same root, if that makes any sense.In other words, I could get the first and last breadcrumbs without problems but getting the second was a bit difficult without something to tell the system which second generation crumb to use.
 
 The other option you suggested I did play around with but was never able to totally figure it out.I'm assuming it's intended to be utilized in a CF script and I don't have too much experience with CF scripting.
 
 Thanks for your help,
 --Anne

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
Thanks for the tip barneyb, I replaced session with request and it still works beautifully.

I agree that it's not much of an issue with breadcrumb generation.I'm never going to need more than one set of breadcrumbs on a requesting page so hopefully I'm pretty safe with what I have.

Thanks again,
--Anne

I'd recommend using the request scope, rather than the session scope. 
A breadcrumb display is not bound to a user session in any way, it's
strictly related to the current request.

Joe's suggestion to use the custom tag framework that CF provides is
superior even to that, because it allows multiple invocations of the
tag on a single request to remain totally independant, but that's
probably not much of an issue with breadcrumb generation.

cheers,
barneyb

On Tue, 24 Aug 2004 17:24:01 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




RE: Creating a List from a Recursion

2004-08-24 Thread Dennis Powers
 Currently the breadcrumbs display directly from the custom
 tag which works relatively well.Except there are instances
 when I would really like to have the data placed into a list.
 Any ideas how I could accomplish this?

You need to build the list successively with each recursion and then pass it
back the to calling routine.We do this with a breadcrumb tag we wrote for
our applications.

In our case we wanted a list of the ID numbers of the levels that were
recursed.So we created a variable Levellist that gets passed to the
recursive routine as an attribute then in the routine we executed this
command

cfset LevelList = ListPrepend(#Attributes.LevelList#,
#GetLevel.ParentItemID#)

then at the end of the routine we pass it back

cfset Caller.Levellist=LevelList


Best Regards,

Dennis Powers
UXB Internet- A Website Design and Hosting Company
690 Wolcott Road - P.O. Box 6028
Wolcott, CT 06716 tel: (203)879-2844
http://www.uxbinternet.com
http://dennis.uxb.net
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




RE: DHTML recursion problem

2004-07-29 Thread Micha Schopman
Just a word of advice, place the entire business logic of recursion in a
stored procedure. What you do know, is make numerous calls to the
database server, which is by far, more slower and cpu intensive than
putting the job at SQL Server.

 
tSQL gives you enough functions and possibilities to get recursive
functions.

 
This means, you only call the database once, and then you get a nice
result set back ready to use.

Micha Schopman
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: DHTML recursion problem

2004-07-29 Thread Metzy Martinez
It's extremely fustrating. I'm trying to convert JAVA code into coldFusion and i tried to go with CFTREE but there is a problem with it ColdFusion 5 server. I tried to implement the recursive tree function found in the o'reilly ColdFusion 5 book. that of course is using CFtree.
ughhh.

thanks for your help :)
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




ColdFusion/DHTML recursion tree

2004-07-28 Thread Metzy Martinez
Hello,

I'm trying to create windows explorer style directory structure. And I'm some issues. My folder end up nesting inside of themselves.

Here is my code its a custom tag that calls itself when it finds children

cfoutput

cfif isdefined(attributes.parentItemIdx)
	cfset parentItemId=#attributes.parentItemIdx#

cfelse
	cfset parentItemId = 0
/cfif

cfquery name=get_parents
	SELECT 
		*
	FROM
		participant_assess_actn_doc
	WHERE
		path_name = '#parentItemId#'
	ORDER BY 
		file_name
/cfquery

cfloop query=get_parents
 cfif get_parents.recordcount gt 0
		div id=#get_parents.participant_assess_actn_doc_id# class='FolderOff' >
	cfelse
		div id=#get_parents.participant_assess_actn_doc_id# class='FolderOff' >
	/cfif
	img src='' border='0' id='folder#get_parents.participant_assess_actn_doc_id#'
	span id='texthtml#get_parents.participant_assess_actn_doc_id#' value='#get_parents.participant_assess_actn_doc_id#'#file_name#/span
	/div
	cfquery name=get_children
		SELECT 
			*
		FROM
			participant_assess_actn_doc	
		WHERE
			path_name = '#get_parents.participant_assess_actn_doc_id#'
	/cfquery
	 
	
	

	cfif get_children.recordcount gt 0
	 	span class='branch' id='branch#get_parents.participant_assess_actn_doc_id#'
	/cfif
	cfif #get_parents.participant_assess_actn_doc_id#EQ #parentItemId#
		
		cfmodule template=JMenuBuilder.cfmqass_data_source=d018_reacs_qass parentItemIdx= #get_parents.participant_assess_actn_doc_id#
	/CFIF
/CFLOOP
/cfoutput

Thanks in advance for any help :)
Metzy
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




DHTML recursion problem

2004-07-28 Thread Metzy Martinez
Hello,

I'm trying to create windows explorer style directory structure. And I'm some issues. My folder end up nesting inside of themselves.

Here is my code its a custom tag that calls itself when it finds children

cfoutput

cfif isdefined(attributes.parentItemIdx)
	cfset parentItemId=#attributes.parentItemIdx#

cfelse
	cfset parentItemId = 0
/cfif

cfquery name=get_parents
	SELECT 
		*
	FROM
		participant_assess_actn_doc
	WHERE
		path_name = '#parentItemId#'
	ORDER BY 
		file_name
/cfquery

cfloop query=get_parents
 cfif get_parents.recordcount gt 0
		div id=#get_parents.participant_assess_actn_doc_id# class='FolderOff' >
	cfelse
		div id=#get_parents.participant_assess_actn_doc_id# class='FolderOff' >
	/cfif
	img src='' border='0' id='folder#get_parents.participant_assess_actn_doc_id#'
	span id='texthtml#get_parents.participant_assess_actn_doc_id#' value='#get_parents.participant_assess_actn_doc_id#'#file_name#/span
	/div
	cfquery name=get_children
		SELECT 
			*
		FROM
			participant_assess_actn_doc	
		WHERE
			path_name = '#get_parents.participant_assess_actn_doc_id#'
	/cfquery
	 
	
	

	cfif get_children.recordcount gt 0
	 	span class='branch' id='branch#get_parents.participant_assess_actn_doc_id#'
	/cfif
	cfif #get_parents.participant_assess_actn_doc_id#EQ #parentItemId#
		
		cfmodule template=JMenuBuilder.cfmqass_data_source=d018_reacs_qass parentItemIdx= #get_parents.participant_assess_actn_doc_id#
	/CFIF
/CFLOOP
/cfoutput

Thanks in advance for any help :)
Metzy
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: ColdFusion/DHTML recursion tree

2004-07-28 Thread Matt Robertson
Not sure what the question is here.

However, I built one of these, and released it as a free tag.It
doesn't use layers or anything fancy.The code is very, very simple,
the tree is persistent and the html is easy to modify to whatever
suits you.I came up with a color-coded variant that uses colors and
fonts based on the indent level, rather than having a tree look. 
Gotta get that one posted someday.

http://mysecretbase.com/treemonger.cfm

-- 
--Matt Robertson--
MSB Designs, Inc.
mysecretbase.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: DHTML recursion problem

2004-07-28 Thread stylo stylo
I don't know, but it's a nasty way to do it. 

First of all, you don't need to call every function in the onclick (lowercase, not camelCase). Just send the needed var to a function and go from there.

Secondly, you should not even have cf put onclick inline; just have a class on the nec. menu items, then use js to add the onclick via a getElementsByClassName script. The images can also be background images associated with a class.

See here for some ideas:
http://www.kryogenix.org/code/browser/aqlists/

I understand, however, if you are stuck with a script that's not yours :-(
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Using recursion with query results

2004-05-17 Thread nancy . tracy
I'm trying to build a recursive routine that will go through my query
results and display them in a tree structure.There are four fields in each
row of my results.Is it possible for me to pass an entire row of my query
results to a custom tag?If so, when I come back out of my recursive
routine, will CF know that that row has been processed?Or is it best for
me to throw all my query results into a structure then run the recursive
routine?

I've done this in ASP, but I'm at a loss in ColdFusion.I know this should
be easy, but

Nancy P. Tracy
Electrical Design and Web Development
GE Global Controls Services
3800 N. Wilson Ave.
Loveland, CO 80538
970.461.5273
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Using recursion with query results

2004-05-17 Thread Barney Boisvert
If you're tree-ing the recordset, I assume that you have a itemID/parentID
field coupling?Here's the basic algorithm that I use to perform such a
convertion:

cffunction name=makeTree
cfargument name=rs /
cfargument name=parentID default= /
cfargument name=level default=0 /
cfloop query=rs
 cfif rs.parentID EQ parentID
cfoutput#repeatString(nbsp; , level)##rs.name#br //cfoutput
cfset makeTree(rs, itemID, level + 1) /
 /cfif
/cfloop
/cffunction

Keep in mind that this isn't particularly efficient (even with optimization)
and that you should try to cache the generated tree in some form or another,
rather than regenerating it every request.If you need to generate it every
request, then you're probably better of using a different storage mechanism
(the Nested Set Model, is one).

Cheers,
barneyb

Cheers
barneyb

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: Monday, May 17, 2004 1:12 PM
 To: CF-Talk
 Subject: Using recursion with query results
 
 I'm trying to build a recursive routine that will go through my query
 results and display them in a tree structure.There are four 
 fields in each
 row of my results.Is it possible for me to pass an entire 
 row of my query
 results to a custom tag?If so, when I come back out of my recursive
 routine, will CF know that that row has been processed?Or 
 is it best for
 me to throw all my query results into a structure then run 
 the recursive
 routine?
 
 I've done this in ASP, but I'm at a loss in ColdFusion.I 
 know this should
 be easy, but
 
 Nancy P. Tracy
 Electrical Design and Web Development
 GE Global Controls Services
 3800 N. Wilson Ave.
 Loveland, CO 80538
 970.461.5273
 
 
 

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Using recursion with query results

2004-05-17 Thread Ian Skinner
I think your friend may be the array notion for a ColdFusion record set.Try playing with these and see if this doesn't lead somewhere.

 
The following forms are perfectly legal ways to reference record sets.

 
query.columnName[row]
query[columnName][row]

 
Also if you are using a cfoutput query= or a cfloop query= #currentRow# is a system variable of the current row (duh) that the loop is in.

 
Hopefully these will get you on the right track.

Confidentiality Notice:This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re:strange cfc recursion issue...

2004-01-21 Thread Isaac Dealey
Not that it helps much, but I took your same code and had no issues when I
cfdumped the result of getMetaData on an instance of it. You running MX
6.1?

Yeah, I'm running Red Sky ... Turned out Sean was right, I had accidentally horqued up the meta data prior and needed to restart the cf server to fix it. A strategic duplicate() fixed the problem that originally hozed the meta data. 

Those particular functions that are being called as this.function() in this component are all supposed to be public functions. Mostly getValue() and setValue() (a standardized public interface for getting and setting properties), so if calling them as this.getValue() or this.setValue() causes a problem, then there's something else wrong with the code. 

Thanks for having a look at it for me Ray, I really appreciate you taking the time. :)
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




strange cfc recursion issue...

2004-01-19 Thread S . Isaac Dealey
I've got this issue with a component I've been working on... it's
trully bizarre... a description of the issue is on my blog here:

http://www.turnkey.to/ontap/blog/?20040119

Any suggestions greatly appreciated.

The cfc code is here (sorry for the line breaks):

cfcomponent displayname=ontap author=isaac dealey
email=[EMAIL PROTECTED]
hint=this is the core CFC for the onTap framework. All other CFC's in
the ontap framework should ultimately extend this cfc for
introspection and other core architectural functionality
	cfproperty name=abspath type=string required=true hint=the
absolute path of the directory containing the current CFC
	cfproperty name=watch type=struct required=false hint=a
structure of arrays containing references to objects interrested in
the properties of this CFC
	cfproperty name=extends type=array required=false hint=an
array of CFC's from which the current component is extended using the
function mx_core/mx.cfcExtend

	cffunction name=init output=true
	hint=initializes the CFC with required properties, etc.
		!--- this protected variable allows many of the other cfinclude
related functions to work propertly using the getRelative() method
---
		cfset this.setValue(abspath,getdirectoryfrompath(getcurrenttempla
tepath()))
		cfset this.setValue(watch,structnew())
		cfreturn true
	/cffunction

	cffunction name=getMetaFunctionsDefaults returntype=boolean
output=true access=private
	hint=appends default values to the meta data of a function
		cfargument name=mymethod type=struct required=true hint=the
function metadata to append defaults
		cfparam name=mymethod.returntype type=string default=
		cfparam name=mymethod.output type=boolean default=true
		cfparam name=mymethod.access type=string default=public
		cfparam name=mymethod.hint type=string default=
		cfparam name=mymethod.example type=string default=
		cfparam name=mymethod.roles type=string default=
		cfreturn true
	/cffunction

	cffunction name=getMetaPropertiesDefaults returntype=boolean
output=true access=private
	hint=appends default values to the meta data of a cfc property
		cfargument name=property type=struct required=true hint=the
property metadata to append defaults
		cfparam name=property.required type=boolean default=false
		cfparam name=property.type type=string default=Any
		cfparam name=property.default default=n/a
		cfparam name=property.hint default=
		cfreturn true
	/cffunction

	cffunction name=getMetaStruct returntype=struct output=true
access=private
	hint=returns a structure containing all methods (including
inherited) from the current component with keys matching method
names
		cfargument name=metatype type=string required=true
hint=function|property = name of array to convert to structure with
ancestor information
		cfargument name=myobject type=struct
default=#getMetaData(this)# hint=a CFC metadata structure to search
-- defaults to the current CFC
		cfset var mymeta = structnew()
		cfset var objmeta = false

		cfif structkeyexists(myobject,metatype)
			cfset objmeta = myobject[metatype]
			cfloop index=x from=1 to=#arraylen(objmeta)#
cfparam name=myobject.library type=string default=core
cfset objmeta[x].cfcfile = myobject.path
cfset objmeta[x].cfcpath = myobject.name
cfset objmeta[x].cfcname = myobject.displayname
cfset objmeta[x].cfclibrary = myobject.library
cfset evaluate(getMeta#metatype#Defaults(objmeta[x]))
cfset mymeta[objmeta[x].name] = objmeta[x]
			/cfloop
		/cfif

		cfif structkeyexists(myobject,extends)
			and isstruct(myobject.extends)
			and structkeyexists(myobject.extends,displayname)
			cfset
structappend(mymeta,getMetaStruct(metatype,myobject.extends),false)
		/cfif

 		cfreturn mymeta
	/cffunction

	cffunction name=tdoc returntype=string output=true
access=public
		cfargument name=xml type=boolean required=false
default=false
		hint=toggles the returned string between html and SPEC formatted
xml content

		cfset var mydocs = 
		cfset var mydata = getMetaData(this)
		cfset var methods = getMetaStruct(functions,mydata)
		cfset var properties = getMetaStruct(properties,mydata)
		cfset var mymethod = false
		cfset var property = false
		cfset var arglist = false
		cfset var arg = false
		cfset var authorxref = false
		cfset var ancestor = mydata.extends
		cfset var extends = false
		cfset var libraries = false
		cfset var library = false
		cfset var x = false
		cfset var y = false
		cfset var z = false

		cfparam name=mydata.hint type=string default=
		cfparam name=mydata.example type=string default=
		cfparam name=mydata.author type=string default=
		cfparam name=mydata.email type=string default=

		!--- get additional pseudo-inheritance data for CFC's extended with
mx_core/mx.cfcExtend ---
		cfset extends = this.getValue(extends)
		cfif isarray(extends)
			!--- cfloop condition=structkeyexists(ancestor,'displayname')
			cfset ancestor = ancestor.extends/cfloop ---
			cfloop index=x from=1 to=#arraylen(extends)#
			cfset ancestor.extends = getMetaData(extends[x])
	

RE: strange cfc recursion issue...

2004-01-19 Thread Raymond Camden
As just an FYI, when calling methods inside a CFC, you should NOT use

this.METHOD()

instead, you should use

METHOD()

Why? When you use this.METHOD(), it acts as if you were calling the method
from the outside. That means you will be prevented from calling private
methods.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: strange cfc recursion issue...

2004-01-19 Thread Raymond Camden
Not that it helps much, but I took your same code and had no issues when I
cfdumped the result of getMetaData on an instance of it. You running MX
6.1?
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Recursion and Breadcrumbs

2003-12-03 Thread Andre Turrettini
Jake, I did something that might help you.Its a recursive function that
uses one db call.You can see it at work by creating an account and
creating a survey here.www.surveys.theanticool.com
http://www.surveys.theanticool.com .The interface to create the survey
uses only ie at this point(I know I know!).You can see the results of the
nested tree structure as the shape of the survey.Check it out and write
back to me at [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]if you want
more details.I'll get back to you tonight.

 
DRE

-Original Message-
From: Jake . [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 25, 2003 1:22 PM
To: CF-Talk
Subject: Re:Recursion and Breadcrumbs

Really need a dynamic, DB driven solution. I will check out that site
though.

Jake

if ur using dw then just use an extension, takes 5 seconds to do. or once
again go to www.dwfaq.com and go to snippetts and massimo has a few
breadcrumb snippetts there 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Recursion and Breadcrumbs

2003-11-25 Thread Dominik Schlaepfer
Hi Jake

There is an article about recursion from Steve Majewski on defusion.com. I think this article answers your questions.
http://www.defusion.com/articles/index.cfm?ArticleID=63

HTH 

Dominik

-Original Message-
From: Jake McKee [mailto:[EMAIL PROTECTED]
Sent: Monday, November 24, 2003 7:51 PM
To: CF-Talk
Subject: Recursion and Breadcrumbs

After searching high and low, I've found quite a few discussions about
using recursion to create breadcrumbs, and other nested categorical
info. It seems to be a pretty common question, and I would expect that
there is a common solution out there, but I can't seem to find one. 

I'm trying to display:

Home  Cat  Sub Cat  Sub Sub Cat  .. Etc.

My DB table looks like :

Cat IDCatNameParentCatID

---

1 CDs0

2 Good CDs1

3 Bad CDs1

4 U22

5 Nsync3

This would display:

Home  CDs  Good CDs  U2

Anyone have a straightforward code snippet for this?

Thanks!
Jake

--

My Blog -http://www.countersinkdg.com www.countersinkdg.com 




 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Recursion and Breadcrumbs

2003-11-25 Thread Dominik Schlaepfer
Jake

No it does not! In the lower section of the article, just over the source code of the recursive Custom Tag, it is written: To get CFX_MakeTree to put the items in any other order, you would have to completely reorganize your database, and nobody wants to do that.An alternative to hours of swapping ItemID's is to use a small, recursive, custom tag.For example: And here comes your solution without any CFX-Tag.

HTH 

Dominik

-Original Message-
From: Jake . [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 25, 2003 8:36 PM
To: CF-Talk
Subject: Re:Recursion and Breadcrumbs

The problem with that article is that it uses the CF_MakeTree tag, which I'm not able to use. 

Any other ideas?

There is an article about recursion from Steve Majewski on defusion.
com. I think this article answers your questions.
http://www.defusion.com/articles/index.cfm?ArticleID=63

 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Recursion and Breadcrumbs

2003-11-24 Thread Jake McKee
After searching high and low, I've found quite a few discussions about
using recursion to create breadcrumbs, and other nested categorical
info. It seems to be a pretty common question, and I would expect that
there is a common solution out there, but I can't seem to find one. 

I'm trying to display:

Home  Cat  Sub Cat  Sub Sub Cat  .. Etc.

My DB table looks like :

Cat IDCatNameParentCatID

---

1 CDs0

2 Good CDs1

3 Bad CDs1

4 U22

5 Nsync3

This would display:

Home  CDs  Good CDs  U2

Anyone have a straightforward code snippet for this?

Thanks!
Jake



--

My Blog -http://www.countersinkdg.com www.countersinkdg.com 




 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Recursion and Breadcrumbs

2003-11-24 Thread Hagan, Ryan Mr (Contractor ACI)
This is what I generally use.Let me know if you need clarification.

cffunction name=list_categories returntype=string output=No
 cfargument name=myCatId type=numeric default=0 required=true

 cfset var currQuery = 
 cfset var returnString = 

 cfquery name=currQuery datasource=#request.dsn.name#
username=#request.dsn.user# password=#request.dsn.pass#
 SELECT catId, parentCatId, catName
 FROM item_categories
 WHERE parentId = #arguments.myCatId# 
 ORDER BY category
 /cfquery

 cfloop query=currQuery
cfset returnString = returnString  catName   gt; 
cfset returnString = returnString  list_categories( Val(currQuery.catId)
)
 /cfloop

 cfreturn returnString

 
/cffunction

-Original Message-
From: Jake McKee [mailto:[EMAIL PROTECTED]
Sent: Monday, November 24, 2003 1:51 PM
To: CF-Talk
Subject: Recursion and Breadcrumbs

After searching high and low, I've found quite a few discussions about
using recursion to create breadcrumbs, and other nested categorical
info. It seems to be a pretty common question, and I would expect that
there is a common solution out there, but I can't seem to find one. 

I'm trying to display:

Home  Cat  Sub Cat  Sub Sub Cat  .. Etc.

My DB table looks like :

Cat IDCatNameParentCatID

---

1 CDs0

2 Good CDs1

3 Bad CDs1

4 U22

5 Nsync3

This would display:

Home  CDs  Good CDs  U2

Anyone have a straightforward code snippet for this?

Thanks!
Jake

--

My Blog -http://www.countersinkdg.com www.countersinkdg.com 


_


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




problems with recursion in cfmx

2003-10-08 Thread Jason Wagstaff
I don't know if this is a possible bug (or maybe i am doing something
wrong), but when using recursion with a query in the function scope
it is overwritten on the next call of the function.i did find a
workaround, but want to know is what is intended.

I have this function which orders sibilings from a result set that is
a hierarchacl tree of nodes with ids and parentids.(btw i know in
oracle 9i this functino exists, but we are running 8i) the query
looks like this:

cfquery name=getStandardRet datasource=test
SELECT upper(name) as uppername, name,level as
depth,frameid,description,parentid 
FROM sn_standard 
START WITH frameid = '#arguments.key#'
CONNECT BY PRIOR frameid = parentid
/cfquery

I call the orderbysibling function by passing the the parent of the
tree.

cfset startid = getStandardRet[frameid][1] /
cfset orderedQuery =
QueryNew(frameid,parentid,depth,name,description) /
cfset QueryAddRow(orderedQuery) /
cfset
QuerySetCell(orderedQuery,frameid,getStandardRet[frameid][1])
cfset QuerySetCell(orderedQuery,depth,getStandardRet[depth][1])
cfset QuerySetCell(orderedQuery,name,getStandardRet[name][1])
cfset
QuerySetCell(orderedQuery,description,getStandardRet[description][1])
cfset
QuerySetCell(orderedQuery,parentid,getStandardRet[parentid][1])
cfset orderbySibling(startid) /

---orderbySibling function
cffunction name=orderbySibling
cfargument name=nodeid required=true /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfloop query=qsiblings
 cfset QueryAddRow(orderedQuery) /
 cfset QuerySetCell(orderedQuery,frameid,qsiblings.frameid)
 cfset QuerySetCell(orderedQuery,depth,qsiblings.depth) 

 cfset QuerySetCell(orderedQuery,name,qsiblings.name)
 cfset
QuerySetCell(orderedQuery,description,qsiblings.description)
 cfset QuerySetCell(orderedQuery,parentid,qsiblings.parentid)
 cfset orderbySibling(qsiblings.frameid) /
/cfloop	
/cffunction

--- this is the workaround 
cffunction name=orderbySibling
cfargument name=nodeid required=true /
cfargument name=foo required=false /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfset arguments.foo = qsiblings /
cfloop query=arguments.foo
 cfset QueryAddRow(orderedQuery) /
 cfset
QuerySetCell(orderedQuery,frameid,arguments.foo.frameid)
 cfset QuerySetCell(orderedQuery,depth,arguments.foo.depth)

 cfset QuerySetCell(orderedQuery,name,arguments.foo.name)
 cfset
QuerySetCell(orderedQuery,description,arguments.foo.description)
 cfset
QuerySetCell(orderedQuery,parentid,arguments.foo.parentid)
 cfset orderbySibling(arguments.foo.frameid) /
/cfloop	
/cffunction

To me it seems that the query(all variables of the function) should
be pushed onto the stack at each time the function is called.the
workaround is a hack that forces the query qsiblings to take a
different scope so that the data will be preserved as it comes up out
of the recursive calls.i have also noticed that if you use a
varialbe in the original calling scope that it is seen as a global
variable in the recursive function and not local to the scope of the
original calling function.

Does anyone know of a good document that it explains all of the
scopes in cfmx and their relationships?

tia,
jason

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Adrian Lynch
In your query put cfset var getStandardRet =  /

 
That may help.

 
Ade

-Original Message-
From: Jason Wagstaff [mailto:[EMAIL PROTECTED]
Sent: 08 October 2003 15:04
To: CF-Talk
Subject: problems with recursion in cfmx 

I don't know if this is a possible bug (or maybe i am doing something
wrong), but when using recursion with a query in the function scope
it is overwritten on the next call of the function.i did find a
workaround, but want to know is what is intended.

I have this function which orders sibilings from a result set that is
a hierarchacl tree of nodes with ids and parentids.(btw i know in
oracle 9i this functino exists, but we are running 8i) the query
looks like this:

cfquery name=getStandardRet datasource=test
SELECT upper(name) as uppername, name,level as
depth,frameid,description,parentid 
FROM sn_standard 
START WITH frameid = '#arguments.key#'
CONNECT BY PRIOR frameid = parentid
/cfquery

I call the orderbysibling function by passing the the parent of the
tree.

cfset startid = getStandardRet[frameid][1] /
cfset orderedQuery =
QueryNew(frameid,parentid,depth,name,description) /
cfset QueryAddRow(orderedQuery) /
cfset
QuerySetCell(orderedQuery,frameid,getStandardRet[frameid][1])
cfset QuerySetCell(orderedQuery,depth,getStandardRet[depth][1])
cfset QuerySetCell(orderedQuery,name,getStandardRet[name][1])
cfset
QuerySetCell(orderedQuery,description,getStandardRet[description][1])
cfset
QuerySetCell(orderedQuery,parentid,getStandardRet[parentid][1])
cfset orderbySibling(startid) /

---orderbySibling function
cffunction name=orderbySibling
cfargument name=nodeid required=true /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfloop query=qsiblings
 cfset QueryAddRow(orderedQuery) /
 cfset QuerySetCell(orderedQuery,frameid,qsiblings.frameid)
 cfset QuerySetCell(orderedQuery,depth,qsiblings.depth) 

 cfset QuerySetCell(orderedQuery,name,qsiblings.name)
 cfset
QuerySetCell(orderedQuery,description,qsiblings.description)
 cfset QuerySetCell(orderedQuery,parentid,qsiblings.parentid)
 cfset orderbySibling(qsiblings.frameid) /
/cfloop 
/cffunction

--- this is the workaround 
cffunction name=orderbySibling
cfargument name=nodeid required=true /
cfargument name=foo required=false /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfset arguments.foo = qsiblings /
cfloop query=arguments.foo
 cfset QueryAddRow(orderedQuery) /
 cfset
QuerySetCell(orderedQuery,frameid,arguments.foo.frameid)
 cfset QuerySetCell(orderedQuery,depth,arguments.foo.depth)

 cfset QuerySetCell(orderedQuery,name,arguments.foo.name)
 cfset
QuerySetCell(orderedQuery,description,arguments.foo.description)
 cfset
QuerySetCell(orderedQuery,parentid,arguments.foo.parentid)
 cfset orderbySibling(arguments.foo.frameid) /
/cfloop 
/cffunction

To me it seems that the query(all variables of the function) should
be pushed onto the stack at each time the function is called.the
workaround is a hack that forces the query qsiblings to take a
different scope so that the data will be preserved as it comes up out
of the recursive calls.i have also noticed that if you use a
varialbe in the original calling scope that it is seen as a global
variable in the recursive function and not local to the scope of the
original calling function.

Does anyone know of a good document that it explains all of the
scopes in cfmx and their relationships?

tia,
jason

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com http://shopping.yahoo.com
_


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Adrian Lynch
Ignore that. I meant to say, in the recursive functions, locally scope your
queries.

 
cfset var yourQuery =  /

 
should do it.

 
Ade

-Original Message-
From: Adrian Lynch [mailto:[EMAIL PROTECTED]
Sent: 08 October 2003 15:08
To: CF-Talk
Subject: RE: problems with recursion in cfmx 

In your query put cfset var getStandardRet =  /

That may help.

Ade

-Original Message-
From: Jason Wagstaff [mailto:[EMAIL PROTECTED]
Sent: 08 October 2003 15:04
To: CF-Talk
Subject: problems with recursion in cfmx 

I don't know if this is a possible bug (or maybe i am doing something
wrong), but when using recursion with a query in the function scope
it is overwritten on the next call of the function.i did find a
workaround, but want to know is what is intended.

I have this function which orders sibilings from a result set that is
a hierarchacl tree of nodes with ids and parentids.(btw i know in
oracle 9i this functino exists, but we are running 8i) the query
looks like this:

cfquery name=getStandardRet datasource=test
SELECT upper(name) as uppername, name,level as
depth,frameid,description,parentid 
FROM sn_standard 
START WITH frameid = '#arguments.key#'
CONNECT BY PRIOR frameid = parentid
/cfquery

I call the orderbysibling function by passing the the parent of the
tree.

cfset startid = getStandardRet[frameid][1] /
cfset orderedQuery =
QueryNew(frameid,parentid,depth,name,description) /
cfset QueryAddRow(orderedQuery) /
cfset
QuerySetCell(orderedQuery,frameid,getStandardRet[frameid][1])
cfset QuerySetCell(orderedQuery,depth,getStandardRet[depth][1])
cfset QuerySetCell(orderedQuery,name,getStandardRet[name][1])
cfset
QuerySetCell(orderedQuery,description,getStandardRet[description][1])
cfset
QuerySetCell(orderedQuery,parentid,getStandardRet[parentid][1])
cfset orderbySibling(startid) /

---orderbySibling function
cffunction name=orderbySibling
cfargument name=nodeid required=true /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfloop query=qsiblings
 cfset QueryAddRow(orderedQuery) /
 cfset QuerySetCell(orderedQuery,frameid,qsiblings.frameid)
 cfset QuerySetCell(orderedQuery,depth,qsiblings.depth) 

 cfset QuerySetCell(orderedQuery,name,qsiblings.name)
 cfset
QuerySetCell(orderedQuery,description,qsiblings.description)
 cfset QuerySetCell(orderedQuery,parentid,qsiblings.parentid)
 cfset orderbySibling(qsiblings.frameid) /
/cfloop 
/cffunction

--- this is the workaround 
cffunction name=orderbySibling
cfargument name=nodeid required=true /
cfargument name=foo required=false /

cfquery name=qsiblings dbtype=query
 select frameid,depth,name,description,parentid
 from getStandardRet
 where parentid = '#nodeid#'
 order by uppername
/cfquery

cfset arguments.foo = qsiblings /
cfloop query=arguments.foo
 cfset QueryAddRow(orderedQuery) /
 cfset
QuerySetCell(orderedQuery,frameid,arguments.foo.frameid)
 cfset QuerySetCell(orderedQuery,depth,arguments.foo.depth)

 cfset QuerySetCell(orderedQuery,name,arguments.foo.name)
 cfset
QuerySetCell(orderedQuery,description,arguments.foo.description)
 cfset
QuerySetCell(orderedQuery,parentid,arguments.foo.parentid)
 cfset orderbySibling(arguments.foo.frameid) /
/cfloop 
/cffunction

To me it seems that the query(all variables of the function) should
be pushed onto the stack at each time the function is called.the
workaround is a hack that forces the query qsiblings to take a
different scope so that the data will be preserved as it comes up out
of the recursive calls.i have also noticed that if you use a
varialbe in the original calling scope that it is seen as a global
variable in the recursive function and not local to the scope of the
original calling function.

Does anyone know of a good document that it explains all of the
scopes in cfmx and their relationships?

tia,
jason

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com http://shopping.yahoo.com
http://shopping.yahoo.com
_

_


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Jason Wagstaff
--- Adrian Lynch [EMAIL PROTECTED] wrote:
 Ignore that. I meant to say, in the recursive functions, locally
 scope your
 queries.

that is essentially what i do with using the arguments.foo and it
solved the problem.but is this what is supppose to happen/intended?
 it seems to me that the the query should be scoped to the local
function automatically.why is it global? why can the other
recursive function calls see it?Are all variables global? I
would prefer to have an understanding of why and how instead of (imo)
a workaround.

jason

 
 -Original Message-
 From: Adrian Lynch [mailto:[EMAIL PROTECTED]
 Sent: 08 October 2003 15:08
 To: CF-Talk
 Subject: RE: problems with recursion in cfmx 
 
 
 In your query put cfset var getStandardRet =  /
 
 
 That may help.
 
 
 Ade
 
 -Original Message-
 From: Jason Wagstaff [mailto:[EMAIL PROTECTED]
 Sent: 08 October 2003 15:04
 To: CF-Talk
 Subject: problems with recursion in cfmx 
 
 I don't know if this is a possible bug (or maybe i am doing
 something
 wrong), but when using recursion with a query in the function scope
 it is overwritten on the next call of the function.i did find a
 workaround, but want to know is what is intended.
 
 I have this function which orders sibilings from a result set that
 is
 a hierarchacl tree of nodes with ids and parentids.(btw i know in
 oracle 9i this functino exists, but we are running 8i) the query
 looks like this:
 
 cfquery name=getStandardRet datasource=test
SELECT upper(name) as uppername, name,level as
 depth,frameid,description,parentid 
FROM sn_standard 
START WITH frameid = '#arguments.key#'
CONNECT BY PRIOR frameid = parentid
 /cfquery
 
 I call the orderbysibling function by passing the the parent of the
 tree.
 
 cfset startid = getStandardRet[frameid][1] /
 cfset orderedQuery =
 QueryNew(frameid,parentid,depth,name,description) /
 cfset QueryAddRow(orderedQuery) /
 cfset
 QuerySetCell(orderedQuery,frameid,getStandardRet[frameid][1])
 cfset
 QuerySetCell(orderedQuery,depth,getStandardRet[depth][1])
 cfset QuerySetCell(orderedQuery,name,getStandardRet[name][1])
 cfset

QuerySetCell(orderedQuery,description,getStandardRet[description][1])
 cfset

QuerySetCell(orderedQuery,parentid,getStandardRet[parentid][1])
 cfset orderbySibling(startid) /
 
 ---orderbySibling function
 cffunction name=orderbySibling
cfargument name=nodeid required=true /
 
cfquery name=qsiblings dbtype=query
select frameid,depth,name,description,parentid
from getStandardRet
where parentid = '#nodeid#'
order by uppername
/cfquery
 
cfloop query=qsiblings
cfset QueryAddRow(orderedQuery) /
cfset QuerySetCell(orderedQuery,frameid,qsiblings.frameid)
cfset QuerySetCell(orderedQuery,depth,qsiblings.depth)


cfset QuerySetCell(orderedQuery,name,qsiblings.name)
cfset
 QuerySetCell(orderedQuery,description,qsiblings.description)
cfset
 QuerySetCell(orderedQuery,parentid,qsiblings.parentid)
cfset orderbySibling(qsiblings.frameid) /
/cfloop 
 /cffunction
 
 --- this is the workaround 
 cffunction name=orderbySibling
cfargument name=nodeid required=true /
cfargument name=foo required=false /
 
cfquery name=qsiblings dbtype=query
select frameid,depth,name,description,parentid
from getStandardRet
where parentid = '#nodeid#'
order by uppername
/cfquery
 
cfset arguments.foo = qsiblings /
cfloop query=arguments.foo
cfset QueryAddRow(orderedQuery) /
cfset
 QuerySetCell(orderedQuery,frameid,arguments.foo.frameid)
cfset QuerySetCell(orderedQuery,depth,arguments.foo.depth) 

 
cfset QuerySetCell(orderedQuery,name,arguments.foo.name)
cfset
 QuerySetCell(orderedQuery,description,arguments.foo.description)
cfset
 QuerySetCell(orderedQuery,parentid,arguments.foo.parentid)
cfset orderbySibling(arguments.foo.frameid) /
/cfloop 
 /cffunction
 
 To me it seems that the query(all variables of the function) should
 be pushed onto the stack at each time the function is called.the
 workaround is a hack that forces the query qsiblings to take a
 different scope so that the data will be preserved as it comes up
 out
 of the recursive calls.i have also noticed that if you use a
 varialbe in the original calling scope that it is seen as a global
 variable in the recursive function and not local to the scope of
 the
 original calling function.
 
 Does anyone know of a good document that it explains all of the
 scopes in cfmx and their relationships?
 
 tia,
 jason
 
 __
 Do you Yahoo!?
 The New Yahoo! Shopping - with improved product search
 http://shopping.yahoo.com http://shopping.yahoo.com
 http://shopping.yahoo.com
_
 
 
_
 
 


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Adrian Lynch
I hope someone will correct me if I'm wrong on this, but...

 
When you don't scope a variable, including a query, in a function, it
defaults to the variables scope, which means it can be seen outside of the
function. To make it local to the function you var scope it, this is what
cfset var queryName =  / does. This kind of makes sense to me, annoying
to have to use cfset for a query though.

 
Are all variables global? No, only if you make them so, or in this case,
don't tell them overwise. Do a dump of the variables scope to see what's in
there, you might be surprised.

 
cfdump var=#VARIABLES# /

 
Also, does anyone know a similar way to see all var scoped variables?
Dumping var doesn't work.

 
Ade

-Original Message-
From: Jason Wagstaff [mailto:[EMAIL PROTECTED]
Sent: 08 October 2003 15:54
To: CF-Talk
Subject: RE: problems with recursion in cfmx 

--- Adrian Lynch [EMAIL PROTECTED] wrote:
 Ignore that. I meant to say, in the recursive functions, locally
 scope your
 queries.

that is essentially what i do with using the arguments.foo and it
solved the problem.but is this what is supppose to happen/intended?
it seems to me that the the query should be scoped to the local
function automatically.why is it global? why can the other
recursive function calls see it?Are all variables global? I
would prefer to have an understanding of why and how instead of (imo)
a workaround.

jason


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Tim Blair
 but is this what is supppose to happen/intended?

Yes.

Any unscoped variable that is created in a function body is
automatically placed in the variables scope, which is global and not
localised to the function, hence future iterations of the same function
can read/overwrite that value.To localise a variable to the function,
prefix it with var:

cffunction name=foo
 cfset bar =  !--- global (in the variables scope) ---
 cfset var bar2 = !--- localised to the function ---
/cffunction

Further info on scopes is in the livedocs:
http://short.badpen.com/?3LL2SK61 

HTH,

Tim.

---
OUR NEW SITE IS NOW LIVE
Visit our new website at http://www.rawnet.com/ and
race around the beautiful Bracknell streets at
http://xmas.rawnet.com/
---
Tim Blair
Web Application Engineer, Rawnet Limited
Direct Phone : +44 (0) 1344 393 441
Switchboard : +44 (0) 1344 393 040
---
This message may contain information which is legally
privileged and/or confidential.If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
---


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Raymond Camden
 Also, does anyone know a similar way to see all var scoped 
 variables? Dumping var doesn't work.


You can't - however - if you need to, simply do:

cfset var local = structNew()

and place all your crap in local, then you can inspect it at will.


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: problems with recursion in cfmx

2003-10-08 Thread Jason Wagstaff
--- Tim Blair [EMAIL PROTECTED] wrote:
  but is this what is supppose to happen/intended?
 
 Yes.
 
 Any unscoped variable that is created in a function body is
 automatically placed in the variables scope, which is global and
 not
 localised to the function, hence future iterations of the same
 function
 can read/overwrite that value.To localise a variable to the
 function,
 prefix it with var:

thanks for the link. that is exactly what i needed.to me, this is
counter-intuitive.i would think that variables declared in a
function would be local to that functionunless i specifically put
them into another scope.(hence the problem i had)but that is me. 
thanks to everyone for the information.

jason

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Recursion and Scope problem?

2003-09-18 Thread Cedric Villat
Ok, I'm doing a bit of recursion, and my variables seem to be overwriting
themselves, which makes no sense to me. Here is my code:

cffunction name=getDTreeWidth returntype=numeric
 cfargument name=node type=string required=yes
 cfargument name=level type=numeric required=yes

 cfset root_node = Arguments.node
 cfset levels = Arguments.level
 cfset children = Request.children
 cfset width = 0

 cfif levels EQ 0
  !--- No more levels to show ---
  cfset width = 1
 cfelseif NOT StructKeyExists(children, root_node) OR
ArrayLen(children[root_node]) LTE 0
  !--- No Children ---
  cfset width = 1
 cfelse
  cfloop from=1 to=#numChildren(root_node)# index=a
   cfset width = width + getDTreeWidth(children[root_node][a], levels - 1)
  /cfloop
 /cfif

 cfreturn width
/cffunction


In this example, the root_node is Homer Simpson. He has 3 children Bart,
Lisa, and Maggie. When the function is first run, Arguments.node is Homer
Simpson. It goes through the code until it gets to the recursive call
getDTreeWidth() which then calls itself for each child. After calling
getDTreeWidth() for Bart, it seems to work. When the function returns a
number and is added to the width, the next time through Homer Simpson's
loop, the root_node is now Bart Simpson! How could the recursive call to
Bart Simpson overwrite Homer Simpson's original arguments? Is this a bug or
am I missing something here?

Any help would be appreciated. It may not make sense, so let me know if you
need some more clarification.

Cedric


~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137530
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com


RE: Recursion and Scope problem?

2003-09-18 Thread Hagan, Ryan Mr (Contractor ACI)
Try using the var keyword in your first four cfset statements.

cfset var root_node = Arguments.node
cfset var levels = ...


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 12:59 PM
To: CF-Talk
Subject: Recursion and Scope problem?


Ok, I'm doing a bit of recursion, and my variables seem to be overwriting
themselves, which makes no sense to me. Here is my code:

cffunction name=getDTreeWidth returntype=numeric
 cfargument name=node type=string required=yes
 cfargument name=level type=numeric required=yes

 cfset root_node = Arguments.node
 cfset levels = Arguments.level
 cfset children = Request.children
 cfset width = 0

 cfif levels EQ 0
  !--- No more levels to show ---
  cfset width = 1
 cfelseif NOT StructKeyExists(children, root_node) OR
ArrayLen(children[root_node]) LTE 0
  !--- No Children ---
  cfset width = 1
 cfelse
  cfloop from=1 to=#numChildren(root_node)# index=a
   cfset width = width + getDTreeWidth(children[root_node][a], levels - 1)
  /cfloop
 /cfif

 cfreturn width
/cffunction


In this example, the root_node is Homer Simpson. He has 3 children Bart,
Lisa, and Maggie. When the function is first run, Arguments.node is Homer
Simpson. It goes through the code until it gets to the recursive call
getDTreeWidth() which then calls itself for each child. After calling
getDTreeWidth() for Bart, it seems to work. When the function returns a
number and is added to the width, the next time through Homer Simpson's
loop, the root_node is now Bart Simpson! How could the recursive call to
Bart Simpson overwrite Homer Simpson's original arguments? Is this a bug or
am I missing something here?

Any help would be appreciated. It may not make sense, so let me know if you
need some more clarification.

Cedric



~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137532
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com


RE: Recursion and Scope problem?

2003-09-18 Thread Ian Skinner
Because you where using the default scope that can be seen by default all
functions can see.  The Var keyword declares the scope private to the
function alone.  

--
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 10:13 AM
To: CF-Talk
Subject: Re:Recursion and Scope problem?


Bingo, worked like a champ. But I'm still wondering WHY the scopes be
overwritten? I just don't get it

Cedric

Try using the var keyword in your first four cfset statements.

cfset var root_node = Arguments.node
cfset var levels = ...


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 12:59 PM
To: CF-Talk
Subject: Recursion and Scope problem?


Ok, I'm doing a bit of recursion, and my variables seem to be overwriting
themselves, which makes no sense to me. Here is my code:

cffunction name=getDTreeWidth returntype=numeric
 cfargument name=node type=string required=yes
 cfargument name=level type=numeric required=yes

 cfset root_node = Arguments.node
 cfset levels = Arguments.level
 cfset children = Request.children
 cfset width = 0

 cfif levels EQ 0
  !--- No more levels to show ---
  cfset width = 1
 cfelseif NOT StructKeyExists(children, root_node) OR
ArrayLen(children[root_node]) LTE 0
  !--- No Children ---
  cfset width = 1
 cfelse
  cfloop from=1 to=#numChildren(root_node)# index=a
   cfset width = width + getDTreeWidth(children[root_node][a], levels -
1)
  /cfloop
 /cfif

 cfreturn width
/cffunction


In this example, the root_node is Homer Simpson. He has 3 children Bart,
Lisa, and Maggie. When the function is first run, Arguments.node is Homer
Simpson. It goes through the code until it gets to the recursive call
getDTreeWidth() which then calls itself for each child. After calling
getDTreeWidth() for Bart, it seems to work. When the function returns a
number and is added to the width, the next time through Homer Simpson's
loop, the root_node is now Bart Simpson! How could the recursive call to
Bart Simpson overwrite Homer Simpson's original arguments? Is this a bug or
am I missing something here?

Any help would be appreciated. It may not make sense, so let me know if you
need some more clarification.

Cedric




~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137535
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm


RE: Recursion and Scope problem?

2003-09-18 Thread Hagan, Ryan Mr (Contractor ACI)
As I understand it ( and I'll be quickly corrected if I'm wrong ), here's
how scope works.

In a CF page, all variables on that page (and cfinclude'd pages) have the
same Global scope...functions included.  By using the var keyword,
you're telling CF to make the declared variable private scope of the
function it was called in.  Another scope issue that I've run across is that
function arguments (cfargument) always have their own, unique scope and
will not be overwritten in a recursive function call.


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 1:13 PM
To: CF-Talk
Subject: Re:Recursion and Scope problem?


Bingo, worked like a champ. But I'm still wondering WHY the scopes be
overwritten? I just don't get it

Cedric

Try using the var keyword in your first four cfset statements.

cfset var root_node = Arguments.node
cfset var levels = ...


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 12:59 PM
To: CF-Talk
Subject: Recursion and Scope problem?


Ok, I'm doing a bit of recursion, and my variables seem to be overwriting
themselves, which makes no sense to me. Here is my code:

cffunction name=getDTreeWidth returntype=numeric
 cfargument name=node type=string required=yes
 cfargument name=level type=numeric required=yes

 cfset root_node = Arguments.node
 cfset levels = Arguments.level
 cfset children = Request.children
 cfset width = 0

 cfif levels EQ 0
  !--- No more levels to show ---
  cfset width = 1
 cfelseif NOT StructKeyExists(children, root_node) OR
ArrayLen(children[root_node]) LTE 0
  !--- No Children ---
  cfset width = 1
 cfelse
  cfloop from=1 to=#numChildren(root_node)# index=a
   cfset width = width + getDTreeWidth(children[root_node][a], levels -
1)
  /cfloop
 /cfif

 cfreturn width
/cffunction


In this example, the root_node is Homer Simpson. He has 3 children Bart,
Lisa, and Maggie. When the function is first run, Arguments.node is Homer
Simpson. It goes through the code until it gets to the recursive call
getDTreeWidth() which then calls itself for each child. After calling
getDTreeWidth() for Bart, it seems to work. When the function returns a
number and is added to the width, the next time through Homer Simpson's
loop, the root_node is now Bart Simpson! How could the recursive call to
Bart Simpson overwrite Homer Simpson's original arguments? Is this a bug or
am I missing something here?

Any help would be appreciated. It may not make sense, so let me know if you
need some more clarification.

Cedric




~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137537
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com


RE: Recursion and Scope problem?

2003-09-18 Thread Andre Turrettini
basically, you call the function once and the vars are declared in the
global scope, when that function calls itself, it redeclares them again in
that same global scope, so they are overwritten.  So, when the top function
continues, its variables are no longer the ones it set.  Using the var
statement simply keeps each declaration seperate.  Make sense?

DRE

-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 11:13 AM
To: CF-Talk
Subject: Re:Recursion and Scope problem?


Bingo, worked like a champ. But I'm still wondering WHY the scopes be
overwritten? I just don't get it

Cedric

Try using the var keyword in your first four cfset statements.

cfset var root_node = Arguments.node
cfset var levels = ...


-Original Message-
From: Cedric Villat [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 12:59 PM
To: CF-Talk
Subject: Recursion and Scope problem?


Ok, I'm doing a bit of recursion, and my variables seem to be overwriting
themselves, which makes no sense to me. Here is my code:

cffunction name=getDTreeWidth returntype=numeric
 cfargument name=node type=string required=yes
 cfargument name=level type=numeric required=yes

 cfset root_node = Arguments.node
 cfset levels = Arguments.level
 cfset children = Request.children
 cfset width = 0

 cfif levels EQ 0
  !--- No more levels to show ---
  cfset width = 1
 cfelseif NOT StructKeyExists(children, root_node) OR
ArrayLen(children[root_node]) LTE 0
  !--- No Children ---
  cfset width = 1
 cfelse
  cfloop from=1 to=#numChildren(root_node)# index=a
   cfset width = width + getDTreeWidth(children[root_node][a], levels -
1)
  /cfloop
 /cfif

 cfreturn width
/cffunction


In this example, the root_node is Homer Simpson. He has 3 children Bart,
Lisa, and Maggie. When the function is first run, Arguments.node is Homer
Simpson. It goes through the code until it gets to the recursive call
getDTreeWidth() which then calls itself for each child. After calling
getDTreeWidth() for Bart, it seems to work. When the function returns a
number and is added to the width, the next time through Homer Simpson's
loop, the root_node is now Bart Simpson! How could the recursive call to
Bart Simpson overwrite Homer Simpson's original arguments? Is this a bug or
am I missing something here?

Any help would be appreciated. It may not make sense, so let me know if you
need some more clarification.

Cedric




~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137564
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com


recursion in cold fusion ( was RE: Creating a list with infinite groupings and indents )

2003-07-09 Thread Hagan, Ryan Mr (Contractor ACI)
This brings up an interesting question for me.  I tend to use recursive
functions frequently, and have even had to solve a problem very similar to
the original question posed in this thread.  My take on the solution is the
following (in php):


itemIDitemparentID
--
 1root   0
 21st level 11
 31st level 21
 41st level 31
 52nd level 1 1  2
 62nd level 1 2  2
 72nd level 3 1  4
etc...

function list_categories( $parentId, $level ) {
global $database, $connection;  
$numSpaces = 5;
$query = SELECT * FROM myTable WHERE parentId =  . $parentId;
$result = mysql_query($query, $connection);
while( $row = mysql_fetch_assoc( $result ) ) {
// output spaces for proper indentation
for ( $spaces=0; $spaces=($level*$numSpaces); $spaces++ )
echo 'nbsp;';
echo 'br\n';
list_categories( $row[itemId], $level+1 );
}
}

// list entire table in tree format
list_categories( 0, 0 );



I personally like this solution quite a bit.  I know it has performance
issues, but I've never noticed any significant impact on server response,
even under heavy load.  To me, this is very clean and very readable code.
I'd love to be able to write this code in CFMX, but for several reasons,
it's just not possible.

First and foremost, we can't run queries inside of cfscript tags.  Bummer.

Second, even if the query issue were resolved (and if you've got ideas for
work-arounds, I'd love to hear them), you've now got variable scope issues.
A variable declared in a CFMX page is global (correct me if I'm wrong) to
the entire page, even inside of functions.  In other words, unlike PHP, CFMX
functions do not have their own scope separate from the rest of the page, so
in the above recursive function, I would be clobbering my $result variable
each time through the recursion.  I've got a workaround for this, but won't
go into here, just making a quick point.


So where does that leave us?  I'd be interested in some info on CFMX CFCs.
Can I use recursion in a CFC function?  If I could, it would certainly fix
the no queries in cfscript problem, however it seems as if it would
break all sorts of good practice rules for CFCs.  How about the second
point above?  Do CFCs have their own variable scope separate from the
calling page (and itself in the case of recursion)?

A lot of problems that are solved with recursion can be rewritten using
while loops.  For this particular problem, though, I've not been able to
come up with a non-recursive solution (assuming the above table structure).
Can anyone help me here?

Thanks for any and all insight into handling recursion in Cold Fusion.


-Original Message-
From: Sarah [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 1:42 PM
To: CF-Talk
Subject: RE: Creating a list with infinite groupings and indents


I think this is pretty much the same thing that others have pointed you 
towards, but I think this article might be easier to read:
http://www.sitepoint.com/article/1105

Sarah



At 7/9/2003 11:10 AM, you wrote:
BTW Joe Clecko had an entire book on trees coming soon

TREES  HIERARCHIES IN SQL (Morgan-Kaufmann), 2003

http://www.celko.com/books.htm

WG


-Original Message-
From: Michael T. Tangorre [mailto:[EMAIL PROTECTED]
Sent: 09 July 2003 14:48
To: CF-Talk
Subject: Re: Creating a list with infinite groupings and indents


First off... the way you have it setup now will only allow for two levels..
level 1 and level 2. To get the ability you are after (tree type
strucutre),
you need to get into nested sets. Joe Celko has done some awesome work in
this area and the links below may help you out. It is a bit tricky at
first,
but once you get it, it is very powerful. The sql statements for
adding/removing/updating children or parents is already written in the
links below and
you can adjust them slightly to work for your situation. I would definitely
start there.

http://www.dbmsmag.com/9603d06.html
http://www.mvps.org/access/queries/qry0023.htm

HTH,

Mike


- Original Message -
From: John Sprenkle [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 9:19 AM
Subject: Creating a list with infinite groupings and indents


  Say I have a table with the following records:
 
  rec id  description  parent id
  1 Test Record 1  0
  2 Test Record 2  1
  3 Test Record 3  1
  4 Test Record 4  3
  5 Test Record 5  3
  6 Test Record 6  4
  7 Test Record 7  4
  8 Test Record 8  3
 
  The parent id field relates a record to its parent. I want to display
the
  records in a list so that children records are listed indented under

RE: recursion in cold fusion ( was RE: Creating a list with infin ite groupings and indents )

2003-07-09 Thread Ian Skinner
I've done what you have done here with both CFC's and before the Custom
Tags.  It's fairly easy to right a recursive custom tag, since each call to
the tag gets it's own attributes scope.

This one is recursing over a Structure creating an indented tree select
list.  It could easily be modified to do the same thing over a query or any
other complex data type.


*** Recursive Custom Tag ***


cfloop from=1 to=#ArrayLen(Attributes.Areas[Attributes.Parent])#
index=i
cfoutput
option
value=#Attributes.Areas[Attributes.Parent][i]['ID']##iif(ListContains(Attr
ibutes.Current,Attributes.Areas[Attributes.Parent][i]['ID']),DE('
selected'),DE(''))##Attributes.Spacer##i#)
#Attributes.Areas[Attributes.Parent][i][Name]#/option
/cfoutput

cfif
StructKeyExists(Attributes.Areas,Attributes.Areas[Attributes.Parent][i][ID
]) AND Attributes.Parent NEQ Attributes.Current
cfset Level = Attributes.Level + 1
cf_areaselectlist areas=#Attributes.Areas#
parent=#Attributes.Areas[Attributes.Parent][i][ID]#
spacer=#Attributes.Spacer#nbsp;nbsp;nbsp; current=#Attributes.Current#
level = #Level#
/cfif
/cfloop

 END 

--
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-Original Message-
From: Hagan, Ryan Mr (Contractor ACI)
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 1:14 PM
To: CF-Talk
Subject: recursion in cold fusion ( was RE: Creating a list with
infinite groupings and indents )


This brings up an interesting question for me.  I tend to use recursive
functions frequently, and have even had to solve a problem very similar to
the original question posed in this thread.  My take on the solution is the
following (in php):


itemIDitemparentID
--
 1root   0
 21st level 11
 31st level 21
 41st level 31
 52nd level 1 1  2
 62nd level 1 2  2
 72nd level 3 1  4
etc...

function list_categories( $parentId, $level ) {
global $database, $connection;  
$numSpaces = 5;
$query = SELECT * FROM myTable WHERE parentId =  . $parentId;
$result = mysql_query($query, $connection);
while( $row = mysql_fetch_assoc( $result ) ) {
// output spaces for proper indentation
for ( $spaces=0; $spaces=($level*$numSpaces); $spaces++ )
echo 'nbsp;';
echo 'br\n';
list_categories( $row[itemId], $level+1 );
}
}

// list entire table in tree format
list_categories( 0, 0 );



I personally like this solution quite a bit.  I know it has performance
issues, but I've never noticed any significant impact on server response,
even under heavy load.  To me, this is very clean and very readable code.
I'd love to be able to write this code in CFMX, but for several reasons,
it's just not possible.

First and foremost, we can't run queries inside of cfscript tags.  Bummer.

Second, even if the query issue were resolved (and if you've got ideas for
work-arounds, I'd love to hear them), you've now got variable scope issues.
A variable declared in a CFMX page is global (correct me if I'm wrong) to
the entire page, even inside of functions.  In other words, unlike PHP, CFMX
functions do not have their own scope separate from the rest of the page, so
in the above recursive function, I would be clobbering my $result variable
each time through the recursion.  I've got a workaround for this, but won't
go into here, just making a quick point.


So where does that leave us?  I'd be interested in some info on CFMX CFCs.
Can I use recursion in a CFC function?  If I could, it would certainly fix
the no queries in cfscript problem, however it seems as if it would
break all sorts of good practice rules for CFCs.  How about the second
point above?  Do CFCs have their own variable scope separate from the
calling page (and itself in the case of recursion)?

A lot of problems that are solved with recursion can be rewritten using
while loops.  For this particular problem, though, I've not been able to
come up with a non-recursive solution (assuming the above table structure).
Can anyone help me here?

Thanks for any and all insight into handling recursion in Cold Fusion.


-Original Message-
From: Sarah [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 1:42 PM
To: CF-Talk
Subject: RE: Creating a list with infinite groupings and indents


I think this is pretty much the same thing that others have pointed you 
towards, but I think this article might be easier to read:
http://www.sitepoint.com/article/1105

Sarah



At 7/9/2003 11:10 AM, you wrote:
BTW Joe Clecko had an entire book on trees coming soon

TREES  HIERARCHIES IN SQL (Morgan-Kaufmann), 2003

http://www.celko.com/books.htm

Re: recursion in cold fusion ( was RE: Creating a list with infinite groupings and indents )

2003-07-09 Thread Paul Hastings
 First and foremost, we can't run queries inside of cfscript tags.
Bummer.

easy enough with a wrapper function.

 Second, even if the query issue were resolved (and if you've got ideas for
 work-arounds, I'd love to hear them), you've now got variable scope
issues.
 A variable declared in a CFMX page is global (correct me if I'm wrong) to

you can make variables private to a function, at least as i understand it.



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: recursion in cold fusion ( was RE: Creating a list with infinite groupings and indents )

2003-07-09 Thread Sean A Corfield
On Wednesday, Jul 9, 2003, at 13:13 US/Pacific, Hagan, Ryan Mr 
(Contractor ACI) wrote:
 function list_categories( $parentId, $level ) {

cffunction name=list_categories
cfargument name=parentId type=numeric
cfargument name=level type=numeric

   global $database, $connection;  
   $numSpaces = 5;

cfset var numSpaces = 5
cfset var result = 0
cfset var spaces = 0
cfset var spaceString = 

   $query = SELECT * FROM myTable WHERE parentId =  . $parentId;
   $result = mysql_query($query, $connection);

cfquery datasource=#request.connection# name=result
SELECT * FROM myTable WHERE parentId = #arguments.parentId#
/cfquery

   while( $row = mysql_fetch_assoc( $result ) ) {

cfloop query=result

   // output spaces for proper indentation
   for ( $spaces=0; $spaces=($level*$numSpaces); $spaces++ )

cfloop index=spaces from=1 to=#level * numSpaces#

   echo 'nbsp;';

cfset spaceString = spaceString  nbsp;
/cfloop
!--- output this category prefixed by spaceString ---

   echo 'br\n';

br /

   list_categories( $row[itemId], $level+1 );

cfset list_categories( result.itemId, level+1 )

   }

/cfloop

 }

 // list entire table in tree format
 list_categories( 0, 0 );

cfset list_categories( 0, 0 )

 I'd love to be able to write this code in CFMX, but for several 
 reasons,
 it's just not possible.

See above. Untested but it should be pretty close.

 First and foremost, we can't run queries inside of cfscript tags.  
 Bummer.

So write the function using tags as above.

 Second, even if the query issue were resolved (and if you've got ideas 
 for
 work-arounds, I'd love to hear them), you've now got variable scope 
 issues.

Not a problem - see above.

 A variable declared in a CFMX page is global (correct me if I'm wrong) 
 to
 the entire page, even inside of functions.

Yes, it's in the variables scope. The solution is to use var to 
declare local variables in a function.

 In other words, unlike PHP, CFMX
 functions do not have their own scope separate from the rest of the 
 page

Wrong - see above.

Sean A Corfield -- http://www.corfield.org/blog/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: recursion in cold fusion ( was RE: Creating a list with infinite groupings and indents )

2003-07-09 Thread Barney Boisvert
Worth mentioning that you can use custom tags in a recursive manner.  I have
several recursive tree generators on various versions of CF that use custom
tags, UDFs and CFC methods.  custom tags and CFFUCTION-based UDFs (including
CFCs) can have CFQUERY tags in them, although if you're making a query
within a recusive call, you're just asking for performance issues.  Might be
unavoidable for certain situations, but it's just as bad as putting a
CFQUERY inside a loop.

barneyb

---
Barney Boisvert, Senior Development Engineer
AudienceCentral
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax   : 360.647.5351

www.audiencecentral.com


 -Original Message-
 From: Paul Hastings [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, July 09, 2003 1:33 PM
 To: CF-Talk
 Subject: Re: recursion in cold fusion ( was RE: Creating a list with
 infinite groupings and indents )


  First and foremost, we can't run queries inside of cfscript tags.
 Bummer.

 easy enough with a wrapper function.

  Second, even if the query issue were resolved (and if you've
 got ideas for
  work-arounds, I'd love to hear them), you've now got variable scope
 issues.
  A variable declared in a CFMX page is global (correct me if I'm
 wrong) to

 you can make variables private to a function, at least as i understand it.



 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: recursion in cold fusion ( was RE: Creating a list with infinite groupings and indents )

2003-07-09 Thread Jochem van Dieten
Hagan, Ryan Mr (Contractor ACI) wrote:
 
 I personally like this solution quite a bit.  I know it has performance
 issues, but I've never noticed any significant impact on server response,
 even under heavy load.

I think it is an ugly workaround. SQL is a set oriented language and the 
best way to use that is by getting the whole set at once. Furthermore it 
is important to keep in mind that your solution does not guarantee to 
return the same order every time.


 First and foremost, we can't run queries inside of cfscript tags.  Bummer.

Declare your cfquery as a cffunction.


 Second, even if the query issue were resolved (and if you've got ideas for
 work-arounds, I'd love to hear them), you've now got variable scope issues.
 A variable declared in a CFMX page is global (correct me if I'm wrong) to
 the entire page, even inside of functions.

Wouldn't cfset var myquery=... solve that?


 So where does that leave us?  I'd be interested in some info on CFMX CFCs.
 Can I use recursion in a CFC function?

Sure you can.


 A lot of problems that are solved with recursion can be rewritten using
 while loops.  For this particular problem, though, I've not been able to
 come up with a non-recursive solution (assuming the above table structure).
 Can anyone help me here?

So don't use that table structure :-)

Use a nested set model, or use a 2 table model where one table holds 
complete trees in an XMLData field (which you only need to edit when a 
new element is inserted) and one holds individual messages but with an 
FK to the table that holds the complete trees in XML.
I usually prefer the first solution, but in some cases the latter 
solution allows you to offload the whole thing to the client and let the 
client figure it out using XSLT. Something like: 
http://spike.oli.tudelft.nl/jochemd/test/tree/test.xml

Jochem



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Recursion Tutorial?

2003-05-30 Thread webguy
BTW the king of Modelling trees in DBs, Joe Celko
(http://www.celko.com/books.htm) , has got an entire book on the subject
coming out, soon
It calles TREES  HIERARCHIES IN SQL 

WG

-Original Message-
From: Chris Montgomery [mailto:[EMAIL PROTECTED]
Sent: 29 May 2003 05:04
To: CF-Talk
Subject: Re: Recursion Tutorial?


Howdy Jake,

Tuesday, May 27, 2003, 11:16:23 PM, Jake McKee wrote:

 ... I am looking for good sources of help/tutorial on recursion. ...

Here's some links I've collected. Most of them relate to hierarchical
database design but you may find them useful anyway. The last article
shows a way to do recursion in CF using a custom tag (which I've used a
couple of times). Anyway, I hope these help.

http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/404
7/index.html

http://www.4guysfromrolla.com/webtech/sqlguru/q121799-1.shtml

http://www.4guysfromrolla.com/webtech/sqlguru/q120899-1.shtml

http://www.dbmsmag.com/9603d06.html

http://www.dbmsmag.com/9604d06.html

http://www.dbmsmag.com/9605d06.html

http://www.sqlmag.com/Articles/Index.cfm?ArticleID=15715

http://www.intelligententerprise.com/001020/celko.shtml

http://www.intelligententerprise.com/001020/celko1_1.shtml

http://www.intelligententerprise.com/010918/414warehouse1_1.shtml/bi%7Cbusin
tel

http://www.databasejournal.com/features/mssql/article.php/1477481

http://www.sqlteam.com/item.asp?ItemID=1602

http://www.sqlteam.com/item.asp?ItemID=1353

http://www.onlamp.com/pub/a/onlamp/2001/07/12/aboutSQL.html

http://www.sqlteam.com/item.asp?ItemID=8866

http://www.sitepoint.com/article.php/1105

http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci537290,00.html

http://www.defusion.com/articles/index.cfm?ArticleID=63

--
Chris Montgomery
Airtight Web Services   http://www.airtightweb.com
Web Development, Web Project Management, Software Sales
210-490-2415
AIM: Airtightweb


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Recursion Tutorial?

2003-05-30 Thread Chris Montgomery
Some more links on recursion I just found:

http://cfhub.com/advanced/customtags/recursion.cfm

http://www.cfhub.com/tutorials/ftp2tree/recursion.cfm

In addition, you might want to search the CF-Talk archives for the
following subject lines:
CF recursive question
Recursive parent/child relationships
How to make recursion in CF
HELP: Hierarchy
Content -Threading?
Recursion in CF

Most of the above threads that I saved were in 2000/2001, don't know how
far back Michael's archives go.

-- 
Chris Montgomery
Airtight Web Services   http://www.airtightweb.com
Web Development, Web Project Management, Software Sales
210-490-2415
AIM: Airtightweb

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Recursion Tutorial?

2003-05-29 Thread Chris Montgomery
Howdy Jake,

Tuesday, May 27, 2003, 11:16:23 PM, Jake McKee wrote:

 ... I am looking for good sources of help/tutorial on recursion. ...

Here's some links I've collected. Most of them relate to hierarchical
database design but you may find them useful anyway. The last article
shows a way to do recursion in CF using a custom tag (which I've used a
couple of times). Anyway, I hope these help.

http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/index.html

http://www.4guysfromrolla.com/webtech/sqlguru/q121799-1.shtml

http://www.4guysfromrolla.com/webtech/sqlguru/q120899-1.shtml

http://www.dbmsmag.com/9603d06.html

http://www.dbmsmag.com/9604d06.html

http://www.dbmsmag.com/9605d06.html

http://www.sqlmag.com/Articles/Index.cfm?ArticleID=15715

http://www.intelligententerprise.com/001020/celko.shtml

http://www.intelligententerprise.com/001020/celko1_1.shtml

http://www.intelligententerprise.com/010918/414warehouse1_1.shtml/bi%7Cbusintel

http://www.databasejournal.com/features/mssql/article.php/1477481

http://www.sqlteam.com/item.asp?ItemID=1602

http://www.sqlteam.com/item.asp?ItemID=1353

http://www.onlamp.com/pub/a/onlamp/2001/07/12/aboutSQL.html

http://www.sqlteam.com/item.asp?ItemID=8866

http://www.sitepoint.com/article.php/1105

http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci537290,00.html

http://www.defusion.com/articles/index.cfm?ArticleID=63

-- 
Chris Montgomery
Airtight Web Services   http://www.airtightweb.com
Web Development, Web Project Management, Software Sales
210-490-2415
AIM: Airtightweb

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Help with CFC and recursion?

2003-05-27 Thread Shawn Grover
Thanks for the tips Sean, Raymond, et al

I had tried using the VAR bit before, but the code choked.  I didn't even
think of doing it in CFSET tags.  (And, I learned that a CFTRY tag is
interpreted as executable code.)  The function is working now.

As for my use of the CFPROPERTY tags, I know they are kinda useless in the
manner I'm using them, EXCEPT for documentation.  If you pull up the CFC in
a browser directly (i.e. http://myserver/mydir/mycfc.cfc), then you get a
very nicely formated page documenting everything there is to know about the
component.  If you don't use the CFPROPERTY tag, then the properties section
is empty.  We are intending to print these screens to document our classes,
so having the properties listed is an added bonus.  Also, some of our
components will likely become web services in the near future - we're still
getting the core code into place so we can proceed with the presentation
layer.

Thanks for the input on recursion, and some tips on CFProperty - on which I
have not been able to find any great details.

Shawn

-Original Message-
From: Sean A Corfield [mailto:[EMAIL PROTECTED]
Sent: Monday, May 26, 2003 8:07 PM
To: CF-Talk
Subject: Re: Help with CFC and recursion?


On Monday, May 26, 2003, at 17:41 US/Pacific, Shawn Grover wrote:
 I've tried a number of combinations for the code, and always seem to 
 get a
 similar result.

You need to use 'var' to declare your variables local - otherwise they 
are just instance variables and get overwritten by each recursive call.

 cfcomponent
   cfproperty name=Category type=caa.intranet.cfc.data.category

Why bother with this if it isn't a Web Service? cfproperty has no 
useful purpose except for type-checking Web Service returns.

   cfscript
   this.Category = createObject(component,
 caa.intranet.cfc.data.category);
   this.Category.Clear();
   this.List = this.Category.List();   
   /cfscript

   cffunction name=BuildTree access=public returntype=string 
   cfset qRoot = getChildren(0)

cfset var qRoot = getChildren(0)

   cfset sTree = 

cfset var sTree = 

   cfloop query=qRoot
   cfset sTree = sTree  AddNode(qRoot.Category_ID,
 qRoot.Category_Name)
   /cfloop
   
   cfreturn sTree
   /cffunction
   
   cffunction name=AddNode access=private returntype=string
 output=no
   cfargument name=CategoryID type=numeric required=Yes
   cfargument name=CategoryName type=string
 required=Yes

cfset var sChild = 
cfset var qChildren = 

   cfscript
   sChild = [#JSStringFormat(Arguments.CategoryName)#,
 'javascript:node_clicked(#Arguments.CategoryID#);', null;
   
   qChildren = getChildren(Arguments.CategoryID);
   for (x=1; x lte qChildren.RecordCount; x=x+1) {
   sChild = sChild 
 AddNode(qChildren.Category_ID[x], qChildren.Category_Name[x]);
   }
   
   sChild = sChild   ], ;
   
   /cfscript 
   
   cfreturn sChild
   /cffunction
   
   cffunction name=getChildren access=public returntype=query 
   cfargument name=ParentID type=numeric required=Yes

cfset var qTemp = this.List
cfset var qChildList = 0

   cfdump var=#Arguments#
   cfset qTemp = this.List

You can delete this line ^^^

   cfquery name=qChildList dbtype=query
   Select *
   From qTemp
   Where Parent_ID = #Arguments.ParentID#;
   /cfquery
   
   cfreturn qChildList
   /cffunction
 /cfcomponent


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Help with CFC and recursion?

2003-05-27 Thread Sean A Corfield
On Tuesday, May 27, 2003, at 13:14 US/Pacific, Shawn Grover wrote:
 As for my use of the CFPROPERTY tags, I know they are kinda useless in 
 the
 manner I'm using them, EXCEPT for documentation.

And of course it all depends on whether you want to use public data 
members - this scope - which you might want to document with 
cfproperty or non-public data members - unnamed scope - which you would 
not want to document with cfproperty (since the documentation is of the 
public interface).

Are other folks relying on cfproperty for auto-documenting public data 
members? How do you deal with keeping the cfproperty tags in sync with 
what you actually do with this scope variables?

Sean A Corfield -- http://www.corfield.org/blog/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



RE: Help with CFC and recursion?

2003-05-27 Thread Shawn Grover
We're declaring a Clear function which initializes the THIS properties to a
valid, known state.  Our procedure is to ensure the clear function matches
the CFPROPERTY declarations, and we call the Clear function when the CFC is
initialized.

-Original Message-
From: Sean A Corfield [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 27, 2003 4:10 PM
To: CF-Talk
Subject: Re: Help with CFC and recursion?

snip/

Are other folks relying on cfproperty for auto-documenting public data 
members? How do you deal with keeping the cfproperty tags in sync with 
what you actually do with this scope variables?

Sean A Corfield -- http://www.corfield.org/blog/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



Re: Help with CFC and recursion?

2003-05-27 Thread Sean A Corfield
On Tuesday, May 27, 2003, at 16:20 US/Pacific, Shawn Grover wrote:
 We're declaring a Clear function which initializes the THIS properties 
 to a
 valid, known state.  Our procedure is to ensure the clear function 
 matches
 the CFPROPERTY declarations, and we call the Clear function when the 
 CFC is
 initialized.

And what's to stop some arbitrary method just setting this.foo to some 
value? (or, worse, some client code that instantiates a CFC and then 
sets the public data)

foo.cfc:
cfcomponent
cfproperty name=bar type=numeric/
cffunction name=clear
cfset this.bar = 0/
/cffunction
...
/cfcomponent

bogus.cfm:
cfset foo = createObject(component,foo)/
cfset foo.clear()/
cfset foo.bar = Hah! I'm a STRING now!/

Sean A Corfield -- http://www.corfield.org/blog/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4



  1   2   >