The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Renaming a tree node
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

corei5

18 Posts

Posted - 01/29/2019 :  3:45:40 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!


yuki_wu

896 Posts

Posted - 01/30/2019 :  12:43:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am sorry that LabTalk doesn’t support this so far.

Regards,
Yuki

OriginLab
Go to Top of Page

corei5

18 Posts

Posted - 01/30/2019 :  11:20:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!


Edited by - corei5 on 01/30/2019 12:12:25 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/30/2019 :  8:22:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

yuki_wu

896 Posts

Posted - 01/30/2019 :  10:17:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page

corei5

18 Posts

Posted - 01/31/2019 :  11:49:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

yuki_wu

896 Posts

Posted - 02/01/2019 :  03:33:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

corei5

18 Posts

Posted - 02/01/2019 :  11:29:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sounds good, I'll give that a try.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000