: : : : I need to read information from something that are similar to a treeview (but it's not). Each level in the "tree" can have an unknown amount of sublevels and so can each sublevel and so on.
: : : :
: : : : Which is the best way to read and store this information? Can I use Stringlists and how will I do it? Any suggestions?
: : : :
: : : : The information I read will be saved to a textfile like this:
: : : :
: : : : Current context: A
: : : : A_1
: : : : A_2
: : : : A_3
: : : : Current context: A_1
: : : : A_1.1
: : : : A_1.2
: : : : A_1.3
: : : : .
: : : : .
: : : : etc
: : : :
: : : : A_1, A_2, A_1.1 etc are sublevels.
: : : :
: : : : /Heinrich
: : : :
: : : Use this to create a str list:
: : :
: : : public
: : : (global VARIABLE--)
: : : var List:Tstringlist;
: : :
: : : ----------------------------
: : :
: : : list := tstringlist.create;
: : :
: : : list.clear;
: : :
: : : list.add('text 1'); // index = 0
: : : list.add('text 2'); // index = 1
: : : list.add('text 3..etc'); //index = 2
: : :
: : : // read data
: : : var i:integer;
: : :
: : : for i:=0 to 2 do begin
: : : memo1.lines.add(list.strings[i]);
: : : end;
: : :
: : :
: :
: : Thanks, but how will I keep track of all the sublevels and the sublevels to them and so on?
: :
: It is possible to add objects to stringlist items. I would suggest something like this:
:
: List.AddObject('Item 1', TStringList.Create);
: // Create an item and include a sublist
: TStringList(List.Objects[0]).AddObject('Item 1.1', TStringList.Create));
: // Create an item in the first sublist and add a subsublist
:
: To get a certain string you need to run a code like this:
:
: s := TStringList(List.Objects[0]).Strings[0];
: // s = now 'Item 1.1'
:
: It is important to type-cast the individual objects, otherwise you cannot access the various properties.
:
Thank you, I will try this out.