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
 access information from notes window
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Andreas_D

Germany
11 Posts

Posted - 11/13/2008 :  04:08:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi everyone,

Origin Version 7.5878, Win XP Pro 2003 SP3.

I am not very experienced with LabTalk script programming and I am currently trying to retrieve information from a notes window and make it accessible in form of variables that can be plotted into a graph text label or exported into an ascii file for archiving reasons.

The data comes from a fluorescence spectrometer and is organized like so:
numeric spectral (X,Y) data in worksheet;
plot in graph window;
experimental data (settings) in notes window;

The notes window contains the data in xml notation: <EXPERIMENT>......<\EXPERIMENT>
I would like to extract some of the experimental parameters and use them in a standard graph template.

Is there a way of doing this in LabTalk?

Your help is much appreciated.

Deanna

China
Posts

Posted - 11/21/2008 :  4:40:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Andreas,

There seems to be no LabTalk method to read information from Notes window in Origin 7.5. However, you may consider saving the information in the Notes window as a file and then reading the information from the file.

LabTalk doesn't have very good method to handle XML files. Probably, you can consider using Origin C. The Tree class supports loading XML files with constructor and the load method.

Suppose you have a simple XML file saved as f:\\temp\\aa.xml. The content is as follows


<xml>
  <exp>aabb</exp>
  <time>13:48</time>
</xml>


You can use the following Origin C function to read the time information in it:


void test7393()
{
	string str = "f:\\temp\\aa.xml";
	
	Tree trConstructor(str);

	string strTest = trConstructor.Time.strVal;

}


LabTalk scripts can call Origin C function. I think we can write an Origin C function to read the XML file and then call it in the script.

Deanna
OriginLab Technical Services

Edited by - Deanna on 11/21/2008 4:58:38 PM
Go to Top of Page

Andreas_D

Germany
11 Posts

Posted - 11/24/2008 :  10:43:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,

thank you very much for your answer. I couldn't get your example to run, though. When I call the test function how can I access the time information afterwards, where does your C-routine put the data into?

And also, how can I store the data from the notes window into a temporary file?

Kind regards,
Andreas
Go to Top of Page

Deanna

China
Posts

Posted - 11/24/2008 :  1:29:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello, Andreas!

To save everything in a notes window to a file on your harddisk, please use the Save command with the -n option. (Please see details here: http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Save_%28command%29#-n.3B_Save_the_winName_notes_window_to_a_file .)

Suppose the name of the notes window is "note1". The following script will save the content of it to f:\temp\test.xml:
save -n note1 f:\temp\test.xml


The Origin C function I wrote last week is just an example to show you that you can read XML files easily with Origin C. The following new one may be more useful.

bool read_info_from_xml(string strXMLPath, string strTNName="time", string strLtStr="%a")
{
	bool bRet = false;
	
	//Load the XML file to a tree
	Tree trConstructor(strXMLPath);
	if (!trConstructor.IsValid()) return bRet;
	
	//Find the treenode with the name 
	TreeNode tn = trConstructor.GetNode(strTNName); 
	if (!tn.IsValid()) return bRet;
	
	bRet = LT_set_str(strLtStr, tn.strVal);
	return bRet;

}

This OC function can find a node in a specific XML file by the name and then save its string value to a LabTalk string variable. Suppose we are still working with the sample XML file in my last post. Running the following script can get the value of time into the string variable %a:
read_info_from_xml("f:\\temp\\test.xml")

Then you can check the value of %a with:
%a=


It should come out with "13:48".

Deanna
OriginLab Technical Services
Go to Top of Page

Andreas_D

Germany
11 Posts

Posted - 11/26/2008 :  05:14:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deanna,

thanks again very much. I can get your routines to work now, and also saving the notes window works fine.

I will now see if I can extract the rather complex xml-structure (which unfortunately also varies from experiment to experiment) into something useful.

Thanks again for your support.

Regards,
Andreas
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