Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2021b (64-bit) 9.8.5.201
Operating System: Windows 10 20H2 (19042.928)
I've searched over labtalk documents and found that because of Tree not an Object, there are no methods for tree type variables, but both String and Datasets type have their Object Methods.
So is there any way to loop over a tree variable, or just list the sibling nodes so I can assign the output to a String Array then loop over it? For example:
tree root;
root.a1.b1.key="A";
root.a1.b2.key="B";
root.a1.b3.key="C";
root.a2.b4.key="D";
root.a2.b5.key="E";
I wanna get the value of the key corresponding to a? and b? in the tree, then I have to set three string arrays, and do two-level nested loops with a if/Switch condition like:
StringArray ary1,ary2,ary3;
ary1.Append("a1 a2");
ary2.Append("b1 b2 b3");
ary3.Append("b4 b5");
loop (ii,1,ary1.GetSize())
{
string nn$,ax$=ary1.GetAt(ii)$;
switch (ii)
{
case 1:
nn$=2;
break;
case 2:
nn$=3;
break;
}
loop (jj,1,ary%(nn$).GetSize())
{
string bx$=ary%(nn$).GetAt(jj)$;
string keyvalue$=root.%(ax$).%(bx$).key$;
keyvalue$=;
}
}
If there is a way to loop over a tree variable's sibling nodes at that level, the code will be more concise without that many ntermediate variables and conditional check.