Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
SamSom
Posted - 07/11/2018 : 09:06:21 AM Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2018; b9.5.0.193; GF3S5-3089-7905886 Operating System: Windows 64-bit
Hi,
Can you please help me to write a condition in a LabTalk script. Please consider the following table as an example. In the table the values of the first 9 rows (0-8th row number) of column B are same as that of column D, while the rest of the values of column B (from 9-19th row number) are same as column C. Here, A has x values, while B, C and D having the y values.
I want to make a condition such that going along the column B when the value of column B matches for the first time with column C, it will print the value of that particular row of column A. I want to use the obtained value to draw a vertical line in the graph using the labtalk command “addline type:=0 value:=* select:=1 name:=vline1”, in which the “*” is the obtained value from column A. I want to use this condition in a loop.
Posted - 07/12/2018 : 05:50:10 AM Might be due to rounding so two values looked the same but actually different.
Maybe replace
if(rb[ii]==rc[ii])
with
if(round(rb[ii],8)==round(rc[ii],8))
CP
SamSom
Posted - 07/12/2018 : 04:51:35 AM Dear Hideo,
Thank you for your help. I tried to use the script but it is showing the message "Not Found" even though column B matches with column C as I showed in my table.
Hideo Fujii
Posted - 07/11/2018 : 4:07:45 PM Hi SamSom,
How about this snippet?
///////////////////////////////////////
//On active worksheet
range ra=col(A);
range rb=col(B);
range rc=col(C);
int found=0; //Flag on finding
int nr=rb.getSize();
for(ii=1; ii<=nr; ii++) { //Loop
if(rb[ii]==rc[ii]) { //Test
found=1; //Set flag
break; //Exit from loop
}
}
if(found) {
window -a Graph1; //Activate your graph
addline type:=0 value:=ra[ii] select:=1 name:=vline1;
}
else type -b Not Found;
///////////////////////////////////////