B4J Question Determine the element's parent

Sergey_New

Well-Known Member
Licensed User
Longtime User
To build a tree structure, I ask you to help determine the parent of an element from the list (lst_level).
I need to get something like this:
idlevelparent_id
100
211
322
422
522
635
746
846
935
1011
1111
1222
1311
1411
1511
1611
1722
1822
1911
An example is attached.
 

Attachments

  • test.zip
    2.4 KB · Views: 119

Sagenut

Expert
Licensed User
Longtime User
B4X:
row(2)=lst_level.IndexOf(lst_level.Get(i))
 
Upvote 0
Solution

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thank you!
I started looking for StackClass, which I've come across before, but couldn't find it.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
row(2)=lst_level.IndexOf(lst_level.Get(i))
Can I ask one more question?
If you add several similar lists to this list, for example like the first one, then how should you change your code?
These will be new parents with level=0.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
These will be new parents with level=0.
I don't think you can have more than one level 0 parent... you can however have multiple higher level parents
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I use a single list of unrelated
thus do not belong to the same mainform.root or activity, but are to be childs of them, right? (I'm trying to understand the why!)
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
I'm trying to understand the why!
For understanding, I am attaching a text file. This is a genealogical data format. I need to build a tree view of this entire file.
 

Attachments

  • Kennedy.zip
    5.4 KB · Views: 100
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Ok, Now I understand... so it is "just" a parsing question...
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
For understanding, I am attaching a text file. This is a genealogical data format. I need to build a tree view of this entire file.
Are you trying to make a GEDCOM interpreter?
Because I think that in this case the work it's completely different.
Or will you manage the data in a different way?
Note that I know nothing about these things...... Just discovered now what they are with this thread.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Are you trying to make a GEDCOM interpreter?
You think correctly.
I did this in VB.NET over ten years ago.
Now I want to reproduce this code in B4A and B4J.
I did the parsing of the file in B4A in the «Поколения» application. I'm missing the tree view of the file itself.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thank you for your rating.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
I managed to establish the parent of the element.
Please help me build the tree. I haven’t figured out how to use recursion to add children.
The project is attached.
 

Attachments

  • GedTree.zip
    27.7 KB · Views: 98
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…