Borland Guru's I need help I have a text file as follows: 1 2 1.1 1.1.1 3.3 2.3 etc I cannot use a control active x tree I need to read this file and 1 is a parent 1.1 is a child of parent 1 and 2 is a parent 2.3 is a child of parent 2 and construct in search a way using arrays or probably a recursive function No xml parsing just read a file. Does any body have a function

0 |

5/5/2009 1:55:35 PM

"Mos" <lndebug@gmail.com> wrote in message news:c1aaeb20-3c1f-408d-9986-bb8d28a87509@s31g2000vbp.googlegroups.com... > I have a text file as follows: > 1 > 2 > 1.1 > 1.1.1 > 3.3 > 2.3 > etc > I cannot use a control active x tree > I need to read this file and 1 is a parent 1.1 is a child of parent > 1 and 2 is a parent 2.3 is a child of parent 2 and construct in > search a way using arrays or probably a recursive function You start with a linear function with considers each line in the file in turn. For every line, a node is added to the tree under the right parent node if you can find it, or at the top level if you can't. Finding the parent node should be easy if the numbering is as you show above. Node labels are a list of names and consecutive prefixes (for 1.1.1, first 1, then 1.1) determine the path through the tree. Is 3.3 a top level node because node 3 wasn't created first, or is parent creation implicit? Do you have a data structure for your tree? Groetjes, Maarten Wiltink

0 |

5/6/2009 9:20:09 AM

"Maarten Wiltink" <maarten@kittensandcats.net> wrote in message news:4a01564a$0$184$e4fe514c@news.xs4all.nl... > "Mos" <lndebug@gmail.com> wrote in message > news:c1aaeb20-3c1f-408d-9986-bb8d28a87509@s31g2000vbp.googlegroups.com... > Is 3.3 a top level node because node 3 wasn't created first, or is > parent creation implicit? > > Do you have a data structure for your tree? Presuming impicit creation one could use something as simple as Type pTreeNode = ^ tTreeNode; tTreeNode = array of integer;

0 |

5/9/2009 1:50:05 AM

BRoberts wrote: > "Maarten Wiltink" <maarten@kittensandcats.net> wrote in message > news:4a01564a$0$184$e4fe514c@news.xs4all.nl... >> Is 3.3 a top level node because node 3 wasn't created first, or is >> parent creation implicit? >> >> Do you have a data structure for your tree? > > Presuming impicit creation one could use something as simple as > > Type > > pTreeNode = ^ tTreeNode; > tTreeNode = array of integer; I'm not seeing the tree. -- Rob

0 |

5/9/2009 5:24:32 AM

"Rob Kennedy" <me3@privacy.net> wrote in message news:76kicgF1dih7sU1@mid.individual.net... > BRoberts wrote: >> "Maarten Wiltink" <maarten@kittensandcats.net> wrote in message >> news:4a01564a$0$184$e4fe514c@news.xs4all.nl... >>> Do you have a data structure for your tree? >> >> Presuming impicit creation one could use something as simple as >> >> Type >> >> pTreeNode = ^ tTreeNode; >> tTreeNode = array of integer; > > I'm not seeing the tree. Every node contains a list of children. The first element is the data. The remaining elements need to be cast to pointer to use ....Perhaps there's a better way. Or you could do away with the pointers altogether and construct a binary tree in a single array with the convention that the parent node is at (index div 2), with left child node at 2*index and right child node at succ(2*index). A neat trick that I've been taught but never used, although I immediately recognised it when my mom showed me an Ahnentafel. Groetjes, Maarten Wiltink

0 |

5/9/2009 8:34:44 AM

"Rob Kennedy" <me3@privacy.net> wrote in message news:76kicgF1dih7sU1@mid.individual.net... > BRoberts wrote: >> "Maarten Wiltink" <maarten@kittensandcats.net> wrote in message >> news:4a01564a$0$184$e4fe514c@news.xs4all.nl... >>> Is 3.3 a top level node because node 3 wasn't created first, or is >>> parent creation implicit? >>> >>> Do you have a data structure for your tree? >> >> Presuming impicit creation one could use something as simple as >> >> Type >> >> pTreeNode = ^ tTreeNode; >> tTreeNode = array of integer; > > I'm not seeing the tree. Sorry I mistyped pTreeNode = ^tTreeNode; tTreeNode = array of pTreeNode;

0 |

5/10/2009 4:42:28 PM