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
 Compare Two Columns 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
abhishek.khare Posted - 05/29/2023 : 08:33:50 AM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: OriginPro 2021b (64-bit) SR1
9.8.5.204

Hello there,

I have a small problem of making conditional statement and execute few lines of code. Following is the code in which I am check values of Col(5) and Col(9) and if they have specific values then setting Col(10) value. But the code does not produce intended output. At the end I should have few 100 and few 200 in Col(9) but I get only 200.
Can anyone advice whats wrong here? I would appreciate. Thanks.

//Get the ranges of the required columns
range ra = [mybk$]acaoasheet$!col(2);
range rf = [mybk$]acaoasheet$!col(5);
range rl = [mybk$]acaoasheet$!col(9);
range r10 = [mybk$]acaoasheet$!col(10);
//Initialize col10 with rf
r10 = rf;
//update the r10 values as per logic below
if ((rf==0) && (rl=="UP"))
{
//r10 = 0.6206*ra+0.4007;
r10 = 100;
}
if ((rf==0) && (rl=="DN"))
{
//r10 = 1*ra;
r10 = 200;
}
2   L A T E S T    R E P L I E S    (Newest First)
abhishek.khare Posted - 05/31/2023 : 03:38:40 AM
Thanks cpyang, much appreciated!

quote:
Originally posted by cpyang

You code show you are just doing column calculations, so why not use column formula?

You are trying to do things in LabTalk code that is much simpler if using formula. For the starter, Labtalk code does not have column (vector) level comparison, like your rf==0, but colume formula dose support such notation.

CP


cpyang Posted - 05/29/2023 : 12:40:04 PM
You code show you are just doing column calculations, so why not use column formula?

You are trying to do things in LabTalk code that is much simpler if using formula. For the starter, Labtalk code does not have column (vector) level comparison, like your rf==0, but colume formula dose support such notation.

CP

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