module Tree_datastructures (a$){ terminal=(,) document b$, all$=a$ report a$ nl$={ } tree=@MakeTree(a$) traverseTree(tree) report b$ all$=b$ clear b$ TraverseTreeIndent(tree) report b$ all$=b$ print b$=a$ all$=(b$=a$)+nl$ clipboard all$ end sub TraverseTree(t as array, Level=1) b$=Level+" "+t#val$(0)+nl$ local i for i=1 to len(t)-1 if t#val(i) is terminal else TraverseTree(t#val(i), Level+1) next end sub sub TraverseTreeIndent(t as array, Level=0) b$=string$("....", Level) +t#val$(0)+nl$ local i for i=1 to len(t)-1 if t#val(i) is terminal else TraverseTreeIndent(t#val(i), Level+1) next end sub function MakeTree(a$) local a$(), c$ a$()=piece$(a$, nl$) local child=terminal, tree=(a$(0),terminal) local Level=2, i, j flush for i=1 to len(a$())-1 if len(a$(i))=0 then continue for j=1 to len(a$(i)) div 2 if left$(a$(i), j*4)<>string$(".", j*4) then c$=mid$(a$(i), (j-1)*4+1) exit for end if next j while j