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
 Set Condition in LabTalk

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
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.

A B C D
0 -877.37112 -877.38525 -877.37112
1 -877.38623 -877.40086 -877.38623
2 -877.39142 -877.40601 -877.39142
3 -877.38947 -877.40368 -877.38947
4 -877.38835 -877.40105 -877.38835
5 -877.393 -877.40359 -877.393
6 -877.39869 -877.40626 -877.39869
7 -877.39793 -877.40358 -877.39793
8 -877.38799 -877.39224 -877.38799
9 -877.38121 -877.38121 -877.3779
10 -877.37988 -877.37988 -877.37594
11 -877.38913 -877.38913 -877.37992
12 -877.39817 -877.39817 -877.38643
13 -877.40141 -877.40141 -877.38795
14 -877.39862 -877.39862 -877.38373
15 -877.39684 -877.39684 -877.38004
16 -877.40329 -877.40329 -877.38317
17 -877.41459 -877.41459 -877.38931
18 -877.42108 -877.42108 -877.38884
19 -877.41834 -877.41834 -877.37799

Thank you in advance.
3   L A T E S T    R E P L I E S    (Newest First)
cpyang 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;
///////////////////////////////////////

Hope this helps.

--Hideo Fujii
OriginLab

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