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
 Forum for Origin C
 how to use user function to set column value?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

austin75

USA
8 Posts

Posted - 04/22/2011 :  09:41:55 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0 SR1
Operating System: windows 7

I have experience on c programing (not using it for more than 10 years), but very new to origin c. Here is my question. I have a workbook with several columns, I can click any one column to make it active. Here comes the first question: how to check which column is active in origin c? Next, I will manually create a new column and use the set column value to fill this column based on the previous active column I was choosing with an user defined function called abcfun. Following is the definition of this function in c. Although I can build this function in code builder smoothly, but I can not get it work when I use it in the "set column values" dialogue. Any suggestions will be highly appreciated. Thanks.


// rr is elements in active column
// tt is the value needed for new column

double abcfun(double rr)
{
double x;
double tt;
if (rr>825)
{x=(2*log(rr)-7.6)/1.8; tt=2.9-3.5*x+2.7*x^2;}
else
{x=(2*log(rr)-4.8)/1.0; tt=47.8-62.9*x+48.9*x^2;}
return tt;
}

Penn

China
644 Posts

Posted - 04/24/2011 :  10:15:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use the GetSelectedColumns method to get the active columns.

After you build the defined function (the one you posted) successfully, you can just use it in the Set Column Values dialog. See the image below:



Penn
Go to Top of Page

austin75

USA
8 Posts

Posted - 04/24/2011 :  10:54:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Penn.

For this user defined function, do I need to include some additional header file to use log() function? Thanks.

A.S.
Go to Top of Page

Penn

China
644 Posts

Posted - 04/25/2011 :  01:19:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi A.S.,

When you use the log function, you need to include the origin.h header file. And this header file is included by default when you create the .c file in Code Builder. So, actually, you don't need to include this header file manually.

Penn
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