General information
Category:
ActiveX controls in VFP
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!
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only