Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nodes in treeview
Message
 
À
29/12/2004 19:21:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00972344
Message ID:
00973145
Vues:
19
I see what you did!!! I was going to start a thread about it a while back. The practice is new to me so I did not understand. By recursive you mean a method calls itself.

I was going to solve a problem that way a few weeks back (have a method call itself) - but I did not know if it was "acceptable". A "circular reference" inihibition was also at play.

It sure simplifies it. Can I consider "recursive" methods an acceptable practice?



>Hi Terry.
>
> (I guess I should not have posted my code:).
>
>That is so not true. My method did the crawling using recursion - your code shows another way to achieve the same thing < s >. It is always good to show alternative ways of reaching the same end. I am really sorry if you took my comment to mean that I thought you shouldn't have posted the code. I just thought that your comment meant that you thought that my code didn't "crawl".
>
>I did not test your code. I did notice that your code used "VARTYPE" to test for a prospective object. I have not been able to make that work inside treeview. I "have" to use TYPE, otherwise - my methods fail
>
>I have never had any problems using VARTYPE() when it is appropriate - whether or not I am inside of a TreeView. Do you have any repro code - I would be interested in seeing what the problem id.
>
>Also, in your code I could not easily discern how, when it got to the last descendent of a root (which could be several generations deep), crawled back to acquire the next available ancestral (or a great ancestral) sibling.
>
>I agree that it is not easy to understand recursive code - writing it gives me a headache < s >. You may want to try tracing through the code by pasting it into a command button on a sample form with a TreeView to see how it works.
>
>Also, your code assumes that Node(1) is the root node. Most of the Time this is the case. But, should a project interactively add nodes to a tree in sorted order, the root node may not always be node(1).
>
>Good point. I probably would have done better to refer to Thisform.oTree.nodes( 1 ).FirstSibling.
>
>Also, I noticed your code does not have a "lastsibling" reference. I could not get my "loop exit" to work properly without a "lastsibling" test. If you can show me how - I would appreciate it.:)
>
>Actually, I did test the code that I posted - initially I was not going to bother - and it does indeed work and exits the loop properly. The best way to understand how it work is to paste it into a command button, set step on, and watch it go.
>
>Hope you have a very Happy New Year!
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform