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
 LabTalk Forum
 Compare Two Columns 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

abhishek.khare

United Arab Emirates
9 Posts

Posted - 05/29/2023 :  08:33:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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;
}

cpyang

USA
1406 Posts

Posted - 05/29/2023 :  12:40:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

abhishek.khare

United Arab Emirates
9 Posts

Posted - 05/31/2023 :  03:38:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


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