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
 Origin Forum
 Set column values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Duff

Argentina
42 Posts

Posted - 08/29/2013 :  6:37:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.0 64
Operating System:win 7

Hi,

I want to calculate the following column values:

IF Col(A)<Col(B) then
Col(C) = Col(A)/Col(B)
else
Col(D) = Col(A)/Col(B)
endif

I've tried it several times but I don't know the code very well.

Thanks!

JacquelineHe

287 Posts

Posted - 08/30/2013 :  05:31:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I suggest you can use Labtalk script to set the columns value.
When the worksheet is active, select "Window: Script Window".
Then in the Script Window enter the following script, highlight them and click "Enter" key.


range aa=col(a); //Access column a on the active worksheet
range bb=col(b);
range cc=col(c);
range dd=col(d);

for( int ii = 1 ; ii <= aa.GetSize() ; ii++ )  //loop all rows
{
   if( aa[ii] < bb[ii] )
       cc[ii] = aa[ii]/bb[ii];
   else 
       dd[ii] = aa[ii]/bb[ii];
};

If you want to know more detail about loop and If Labtalk script, please refer to these online help pages:
http://www.originlab.com/doc/LabTalk/ref/For-cmd
http://www.originlab.com/doc/LabTalk/guide/Flow-of-Control
http://www.originlab.com/doc/LabTalk/ref/If-cmd

Thanks
OriginLab
Jacqueline
Go to Top of Page

snowli

USA
1386 Posts

Posted - 08/30/2013 :  10:14:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Duff,

We support conditional operator.

Expression1 ? Expression2 : Expression3

If expression1 is true, then use expression 2 to do the calculation.
If expression1 is false, use expression 3 to do the calculation.

So in col(C)'s set column values you can enter ( //no expression3 after :)
Col(A)<Col(B)?col(A)/col(B):

In col(D)'s Set Column Values dialog, u can enter
Col(A)>Col(B)?col(A)/col(B):

Thanks, Snow Li
OriginLab Corp.
Go to Top of Page

Duff

Argentina
42 Posts

Posted - 08/31/2013 :  4:27:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Works great
Thanks!
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