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
 XML Import via Origin C function

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/25/2019 : 3:00:13 PM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2018b b9.5.5.409
Operating System: Win 10 64-bit

I would like to import an XML file as a tree variable in Labtalk but I'm not able to access the tree variable I've made with an Origin C function. I have created the following Origin C function to import the XML:


void XML_load(string filename)
{
Tree trLoad(filename);
}


I can compile this code successfully and can run the C function in Labtalk with the following Labtalk script:

XML_load("C:\\Test.xml")

I would like to access the new tree variable "trLoad" in Labtalk but haven't any success. I'm new to programming (i.e., object oriented programming, etc.) which explains my difficulties with this relatively easy task. Please help.

Thanks!
3   L A T E S T    R E P L I E S    (Newest First)
corei5 Posted - 01/25/2019 : 5:27:22 PM
I think I have it now. The Origin C function should look like this:

void XML_load(string filename, string treename)
{
Tree trLoad(filename);
Project.AddTree(treename, trLoad);

}

where treename is the name of my new project level Labtalk tree and filename is the XML file I wish to import.

Then my Labtalk script would look like this:

XML_load("C:\\Test.xml", "NameOfMyLabtalkNewTree")
corei5 Posted - 01/25/2019 : 4:59:06 PM
Thanks Chris!

So would my new Origin C function look like this?

void XML_load(string filename)
{
Tree trLoad(filename);
int TestTree = Project.AddTree(trLoad);
}

I must not have a clear understanding with Project.AddTree because I'm getting compile errors with the above function :(
Chris D Posted - 01/25/2019 : 4:28:42 PM
Hi,

You may use Project::AddTree within your Origin C function to create a project-level Tree variable accessible from LabTalk using the name you assign the Tree to.

See:
https://www.originlab.com/doc/OriginC/ref/Project-AddTree

I'm not sure how well LabTalk will be able to deal with your particular XML though.

Note: it IS a project level variable and will be saved with the project. But this way works to get you the Tree.

I hope this helps!


Thanks,
Chris Drozdowski
Originlab Technical Support

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