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
 Help needed writing a script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ebeldos

Other
1 Posts

Posted - 12/02/2001 :  4:35:54 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello everybody!

I don't know much about programming and I would be really grateful if someone gives me a hand at this. That is my regular routine at the lab and it really consumes allot of my time.

The input data is a file containing 3 columns of numbers. The output is a graph with an exponential decay analysis applied.

The first column contains x-asis data, the third column - y-asis data. The second column contains same number in each line and is not used to build the graph but the number should be written on each output graph.

So what I exactly need from the script is:

1) prompt me for the file to open
2) plot a line
3) apply a 2nd order exponential decay analysis
4) print the number from the second column on the graph
5) print the y0 + A1e^(-k1*x) + A2e^(-k2*x) equation, where ki=1/ti

This would save me hours! Please help me if thats not so hard.

Thanks allot!

Mike

USA
357 Posts

Posted - 12/06/2001 :  10:10:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi ebeldos:

Getting started in Labtalk programming can seem a bit daunting, but the first thing you ought to do is to read the last chapter of your Origin User's Manual (Ch. 18: Programming and Special Topics) and the first two chapters of your LabTalk manual ("Welcome to LabTalk" and "LabTalk"). These three chapters will give you some sense of what LabTalk is about. It would be hard to do anything with LabTalk without some understanding of this material.

One of the things that you may not be aware of is that much of the Origin user-interface functionality is implemented in LabTalk; that is, when you select a menu item, you are often executing LabTalk script. These scripts reside in files in your Origin directory and carry the .OGS file extension. You can actually see which sections of code are being run when you choose a menu command, by doing the following:

Origin 6.0: Open the script window, hold down the CTRL+Shift keys and select a menu command. If the menu command runs a line of LabTalk (some commands are implemented in C and are not accessible) you will see something like:

run.section(FILE,ImportAscii)

This is an actual LabTalk command that instructs Origin to execute the code contained in the section [ImportAscii] in the file FILE.OGS. FILE.OGS is a text file and you can open it with Notepad, browse to the section [ImportAscii] and have a look at the script (just be careful not to alter it).

Origin 6.1: Hold down the CTRL+Shift keys and select a menu command; this will open the relevant .OGS file to the section that performs the menu command, in a LabTalk editor window.

I point this out because most of what you want to do with your script has already been programmed in LabTalk and you can simply "lift" the code straight from Origin .OGS files, using the menu capture procedure outlined above. A start for your script might look something like:

win -t wks %Y\origin; //looks to Origin folder for worksheet template named Origin
run.section(file,ImportAscii); //Opens the Ascii import dialog -- select files
wks.colSel($(wks.ncols),1); //selects the last column of the imported data file -- your Y col
run.section(Plot,Scatter); //creates a scatter plot of the active data set
run.section(Fit,ExpDecay2); //fits a second order exponential decay -- you spec initial parameter values

The three run.section commands actually run whole sections of LabTalk code. The other two lines of code are documented in either the LabTalk Command or Object Reference sections of your LabTalk Manual (...and if you are using Origin 6.1, don't forget the online Help files as they are more up-to-date).

This will not do everything that you have asked for, but it is a good starting point. You may want to create a custom graph template for your final plot that includes text objects with links to calculated parameter values and to the numeric value in your second worksheet column.

But why don't you try running this script line by line, first, just to see what it does? Copy it to your Origin script window, place the cursor in the text just before the semi-colon in each line and press Enter.

Feel free to return to the forum with specific requests (i.e. I now want the script to write the equation to my final graph using the calculated parameter values) and I'm sure that someone will be able to help you out.

Thanks, and good luck.

Mike
Technical Support
OriginLab Corp.
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