T O P I C R E V I E W |
corei5 |
Posted - 01/29/2019 : 3:45:40 PM Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2018b b9.5.5.409 Operating System: Win 10 64-bit
Hello,
I'm trying to rename a tree node in Labtalk. For example, I have a tree node called "testTree.one" and I would like to rename the node called "one" to "two". I haven't had any luck finding this info in the online help manual.
Thanks!
|
7 L A T E S T R E P L I E S (Newest First) |
corei5 |
Posted - 02/01/2019 : 11:29:11 AM Sounds good, I'll give that a try. |
yuki_wu |
Posted - 02/01/2019 : 03:33:56 AM Hi,
I think you could load the tree from the XML file via Origin C directly: https://www.originlab.com/doc/OriginC/ref/Tree-Load and set different ID for the tree nodes that have the same name: https://www.originlab.com/doc/OriginC/ref/TreeNode-ID then access these tree nodes via its ID: https://www.originlab.com/doc/OriginC/ref/tree_get_node_by_id
More info of tree node in Origin C: https://www.originlab.com/doc/OriginC/ref/Tree-GlobalFunction https://www.originlab.com/doc/OriginC/ref/TreeNode
Hope it helps.
Regards, Yuki
OriginLab
|
corei5 |
Posted - 01/31/2019 : 11:49:12 AM I have an XML file that contains additional data about a test I conducted. I would like to pull certain data out of the XML file to attach as text box on a graph of data I created from the test.
So my initial thought was to import the XML as a tree into Labtalk where I can access the data from the XML file easily with the Origin C function "tree". This Origin C function worked very well for importing my source XML file. Only problem is that my source XML file has labeled many sections with the same name so that my newly created Labtalk tree has many children nodes with the same name. This prevents me from accessing the correct child node data because I have four nodes called module (i.e., 4 x tree.module instead of tree.module1, tree.module2, tree.module3, and tree.module4, etc.)
My main goal is to pull the data from the correct tree.module node so I'm thinking renaming the nodes after import to Labtalk should help me tackle this problem.
Please keep in mind I'm pretty new to programming so these solutions I've devised could be complete garbage, lol.
Thanks |
yuki_wu |
Posted - 01/30/2019 : 10:17:40 PM Hi,
1# In Origin C, we have a function tree_rename_tags, for example: https://www.originlab.com/doc/OriginC/ref/tree_rename_tags
void RenameTreeNode()
{
Tree tr;
TreeNode tn1, tn2, tn3;
tn1 = tr.AddNode("node1", 1);
tn2 = tr.AddNode("node2", 2);
tn3 = tn2.AddNode("node21", 3);
out_tree(tr);
StringArray saCurrentNames = {"node2", "node21"};
StringArray saNewNames = {"newNode2", "newNode21"};
tree_rename_tags(tr, saCurrentNames, saNewNames);
out_tree(tr);
}
2# Not sure if this page applies to you. If not, just like CP said, tell me more about your story. https://www.originlab.com/doc/LabTalk/guide/Data-Types-and-vars#Tree
Regards, Yuki
OriginLab
|
cpyang |
Posted - 01/30/2019 : 8:22:23 PM Maybe you can describe your user story? Why do you need to rename a tree tag name? For display purpose, there is separate label attribute that can be used.
CP
|
corei5 |
Posted - 01/30/2019 : 11:20:10 AM Thank you Yuki.
Would you happen to know if it's supported in Origin C? And would you happen to know what sections of the on-line Labtalk manual describes all the tree methods? For exaple, I'm trying to find the description of the tree method "add", i.e., tree.add(), but I'm having no luck.
Thanks!
|
yuki_wu |
Posted - 01/30/2019 : 12:43:24 AM Hi,
I am sorry that LabTalk doesn’t support this so far.
Regards, Yuki
OriginLab
|
|
|