Re: finding child records of child records of child records... with minimal code
This WebDNA talk-list message is from 2000
It keeps the original formatting.
numero = 32717
interpreted = N
texte = Yes, that is a good job for recursion. You want to write an include file that should include itself, with the parameter of the current ID. This will generate the full tree of found records.In pseudo-code form (i.e. this is guaranteed to _not_ run):[Include file=includefile.inc&myID=[ID]] [!] look for top record [/!]and the include file would be:[Search db=file.db&parentID=[myID]][founditems] [ReplaceFoundItems]flag=Y[/ReplaceFoundItems] (if you have 4.0) [Include file=thisfile.inc&myID=[ID]][/founditems][/search]HTHJohn PeacockJohn Butler wrote:> > I have a db full of category records, with these fields:> > ID
parentIDflag> > When I come in a template I use to flag a category record in this db for later deletion,> I also want to find any of its children and flag them also for later deletion, and the> children of those children, and the children of those children, .... going down thru> how ever many levels of children their are.> > I.e. if I want to flag the colors category for later deletion, then I need to also> flag all children of colors (like Blue, Red, Green, etc) for later deletion and> also all children of them (like sky Blue, midnight blue, light red , blood red,> mint green, neon green, etc.)> > I don't know in advance how many levels of children, or children of children, etc...> their may be, nor how many children given a certain level...> > Any ideas how to structure this with just a few lines of code (so I don't have to write> an overkill overestimate number of nested searches/replaces)? Do we call what I am> looking for recursion?> > ?> > -John>-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Yes, that is a good job for recursion. You want to write an include file that should include itself, with the parameter of the current ID. This will generate the full tree of found records.In pseudo-code form (i.e. this is guaranteed to _not_ run):[Include file=includefile.inc&myID=[ID]] [!] look for top record [/!]and the include file would be:[Search db=file.db&parentID=[myID]][founditems] [replacefounditems]flag=Y[/ReplaceFoundItems] (if you have 4.0) [Include file=thisfile.inc&myID=[ID]][/founditems][/search]HTHJohn PeacockJohn Butler wrote:> > I have a db full of category records, with these fields:> > IDparentIDflag> > When I come in a template I use to flag a category record in this db for later deletion,> I also want to find any of its children and flag them also for later deletion, and the> children of those children, and the children of those children, .... going down thru> how ever many levels of children their are.> > I.e. if I want to flag the colors category for later deletion, then I need to also> flag all children of colors (like Blue, Red, Green, etc) for later deletion and> also all children of them (like sky Blue, midnight blue, light red , blood red,> mint green, neon green, etc.)> > I don't know in advance how many levels of children, or children of children, etc...> their may be, nor how many children given a certain level...> > Any ideas how to structure this with just a few lines of code (so I don't have to write> an overkill overestimate number of nested searches/replaces)? Do we call what I am> looking for recursion?> > ?> > -John>-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
John Peacock
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
politeness (was searches with dash...) Please Read (2000)
Mozilla/4. and Browser Info.txt (1997)
Sort on time (2003)
HELP!!! (1998)
Admin Edit prob. (1997)
Limitation of AUTONUMBER (2005)
WebCatalog can't find database (1997)
Letters as SKU (1998)
WebCat2b15MacPlugin - [protect] (1997)
WC2.0 Memory Requirements (1997)
Problems with [Search] param - Mac Plugin b15 (1997)
[Announce] WebCatalog 3.0 Beta Program (1998)
Passing info in [Addlineitem] (1997)
Forms Search Questions (1997)
[WebDNA] 301 redirect (2010)
Frames and WebCat (1997)
Wanted: Broader string manipulation functions (1997)
syntax question, not in online refernce (1997)
problems with 2 tags (1997)
OT: Limit on # of Pulldown entries (1997)