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
 Forum for Origin C
 How to get string out of tree?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

reepingk

Canada
18 Posts

Posted - 03/21/2018 :  5:55:33 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Am I missing something? I'm looking here https://www.originlab.com/doc/OriginC/ref/Tree-GlobalFunction and see no way to output a single tree value as a string? Sure, I can output the entire tree as a string, but that's not really.... helpful.

Also, I found https://www.originlab.com/doc/OriginC/ref/Tree-GetString (not included on the main Tree page for some reason) but that again, only outputs the entire tree as an XML string.


        string tableName;
        string graphName;
        GETN_BOX(titless); //That's "titles" with an extra s
	GETN_STR(tableName, "Table Name?", strPageName); //GETN_STR is outdated on the origin C programming guide E (PDF), it's missing the "_", leading to a good deal of confusion on my part
	GETN_STR(graphname, "Graph Name?", strPageName);
	GetNBox(titless);
//	out_tree(titless,TRUE,TRUE);
//	tableName = tree_get_node_by_id(titless,1,true); //Variable mismatch, I'm assuming tree_get_node_by_id doesn't return a string

// What I want to do below or just use the string variable "tableName" as an intermediate. 
	printf("TableName: " + titless.tableName + "\n");


I'm kinda confused as to why GetNBox returns stuff in such a weird way anyway, although with experience I'm sure I'll eventually understand. I kinda just assumed it'd set the variables to the strings/ints/whatever returned.

EDIT: Yes, I could just use InputBox, but I like to be able to tab from one field to the other and have everything on the same user dialog. (Without having to do string manipulation to split things apart.) And I want to eventually be able to do dropdown lists and stuff, which InputBox can't do (at least not on the same dialog box.)

Origin 2017

Edited by - reepingk on 03/21/2018 6:04:48 PM

Castiel

343 Posts

Posted - 03/21/2018 :  10:23:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by reepingk



        string tableName;
        string graphName;
        GETN_BOX(titless); //That's "titles" with an extra s
	GETN_STR(tableName, "Table Name?", strPageName); //GETN_STR is outdated on the origin C programming guide E (PDF), it's missing the "_", leading to a good deal of confusion on my part
	GETN_STR(graphname, "Graph Name?", strPageName);
	GetNBox(titless);
//	out_tree(titless,TRUE,TRUE);
//	tableName = tree_get_node_by_id(titless,1,true); //Variable mismatch, I'm assuming tree_get_node_by_id doesn't return a string

// What I want to do below or just use the string variable "tableName" as an intermediate. 
	printf("TableName: " + titless.tableName + "\n");





printf("TableName: %s\n", titless.tableName.strVal)


See the following page for more details.

https://www.originlab.com/doc/OriginC/ref/PropertyNode

I deem this page is most useful: https://www.originlab.com/doc/OriginC/ref/Classes


     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 
Go to Top of Page

yuki_wu

896 Posts

Posted - 03/21/2018 :  11:38:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Thank you for pointing out the mistake in PDF file. Yes, the short line between GETN and STR is quite unclear since it is hidden by the hyperlink line. We will improve the PDF file later.

You can check the syntax of tree_get_node_by_id on this page, the function in fact will return a TreeNode not the value of the TreeNode as you expected. Perhaps you have confused the value of the TreeNode and the TreeNode itself.

https://www.originlab.com/doc/OriginC/ref/tree_get_node_by_id

Also, you should set the correct ID at first before you use the function. Use the property TreeNode::ID, you will find that the ID of titless.graphname is actually not 1.

To get the value of a TreeNode, use the method Castiel mentioned above.

To add a dropdown list to GetN dialog, GETN_COMBO should help:
https://www.originlab.com/doc/OriginC/ref/GetN-OriginC#List_Box

Regards,
Yuki
OriginLab
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