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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Renaming a tree node

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000