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
 access information from notes window

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
Andreas_D Posted - 11/13/2008 : 04:08:00 AM
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.
4   L A T E S T    R E P L I E S    (Newest First)
Andreas_D Posted - 11/26/2008 : 05:14:58 AM
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
Deanna Posted - 11/24/2008 : 1:29:53 PM
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
Andreas_D Posted - 11/24/2008 : 10:43:12 AM
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
Deanna Posted - 11/21/2008 : 4:40:49 PM
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

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