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 column/calculate values dialog box in scrip
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

normanja

USA
11 Posts

Posted - 02/02/2006 :  2:56:20 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5g sr3
Operating System: WinXP pro

Hello!

I have a script which I use to import ascii data files with several columns. I name them, erase a few f them and create new ones (and calculate the values therein). Now I want to create new columns which have a formula in them like col(E)=col(C)*col(D) which is autoupdated, i.e. when I change the values of col(D) I do not want to newly calculate col(E), but the program should do it itself. One can access tis kind of functionality through the drop-down menu column/calculate values, enter the formula there, activate autoupdate and it works.

But I want my script to do this for me on 50 freshly mportet datasets (worksheets).

Thanks for your help, appreciated, Norman Schmidt.

Mike Buess

USA
3037 Posts

Posted - 02/02/2006 :  5:25:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need Origin C to access the column formula. First, add the SetColumnFormula function at the bottom to your workspace...
http://www.nmrtools.com/labtalk/tryOC.html

Then use it in a LabTalk script like this...
SetColumnFormula E "col(C)*col(D)";

// Function starts here
void SetColumnFormula(string colName, string strFormula)
{
Worksheet wks = Project.ActiveLayer();
wks.Columns(colName).SetFormula(strFormula);
wks.Columns(colName).SetFormulaAutoUpdate();
}


Mike Buess
Origin WebRing Member
Go to Top of Page

normanja

USA
11 Posts

Posted - 06/02/2006 :  11:51:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
correctly, in Labtalk it has to be


SetColumnFormula(E, "col(C)*col(D)");

Otherwise, it is working great. Thanks!
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/02/2006 :  5:15:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The original expression also uses proper LabTalk syntax and works fine in my tests. When calling an OC function from LabTalk you can omit the parantheses around the arguments as long as you also omit the commas separating the arguments. In general, parentheses are only needed in LabTalk when you expect a return value. See the following section of Help > Programming...

Programming Guide > Programming in Origin C > Calling Origin C Functions > Calling Origin C Functions from LabTalk

Mike Buess
Origin WebRing Member
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