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 for Programming
 LabTalk Forum
 If-condition to generate col out of another col

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
Shock Posted - 07/10/2014 : 1:28:23 PM
Hello everyone!

My problem is the following. I'd like to have a script that is excecuted in Col(B) and checks the data of Col(A). If the value of Col(A) is < 0, than there should be a 0 in Col(B). If the value of Col(A) is not < 0, than there should be this value in Col(B).

I've tried it like

if (Col(A)[i] < 0){
Col(B)[i] = 0
}
[else Col(B)[i]=Col(A)[i];]

but it won't work.

It'd be great to get some help of you guys!
2   L A T E S T    R E P L I E S    (Newest First)
Shock Posted - 07/11/2014 : 10:25:09 AM
Thank you very much, works as intended!
greg Posted - 07/10/2014 : 3:39:53 PM
Your expression would work if you looped over all rows in column A, but as written it will only work for whatever the current value of "i" is (and will fail if "i" does not exist or has a zero or negative value.

You can use the Ternary Operator to achieve what you want in either the Script Window or in Set Column Values:

col(B) = col(A) < 0 ? 0 : col(A)

In Set Column Values for column B you only need the right side:

col(A) < 0 ? 0 : col(A)

Think of "?" as THEN and ":" as ELSE.

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