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
 Origin Forum
 Set column values

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
Duff Posted - 08/29/2013 : 6:37:23 PM
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!
3   L A T E S T    R E P L I E S    (Newest First)
Duff Posted - 08/31/2013 : 4:27:03 PM
Works great
Thanks!
snowli Posted - 08/30/2013 : 10:14:59 AM
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.
JacquelineHe Posted - 08/30/2013 : 05:31:09 AM
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

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