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
 Row row row your data gently down the script...

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
BPrzybyla Posted - 09/24/2013 : 08:45:23 AM
Origin Ver. 8.1G SR1

Hi there,

I'm fairly new to Origin and to its scripting language but I could manage a nice working script so far. One thing though:

Is there a way of comparing each row of a worksheet with each row of another worksheet and dropping all matching values a more elegant way? This is my way of doing this:

range rwA=[%B]DATA_ALL!;
int numrowsA=rwA.maxRows;
range rwM=[%B]MERGE!;
int numrowsM=rwM.maxRows;
int match=0;
loop(ii,1,numrowsA)
	{
	match=0;
		loop(xx,1,numrowsM)
			{
				if([%B]DATA_ALL!Cell(ii,1) == [%B]MERGE!Cell(xx,1))
					match=1;
			};
		if(match == 1)
			{
				[%BnoGK]COMP!Cell(ii,1) = "";
				[%BnoGK]COMP!Cell(ii,2) = "";
				[%BnoGK]COMP!Cell(ii,3) = "";
			};
		else
			{
				[%BnoGK]COMP!Cell(ii,1) = [%B]DATA_ALL!Cell(ii,1);
				[%BnoGK]COMP!Cell(ii,2) = [%B]DATA_ALL!Cell(ii,2);
				[%BnoGK]COMP!Cell(ii,3) = [%B]DATA_ALL!Cell(ii,3);
			};
	};


These recursive loops take a lot of time to complete and I have to cleanup all "blank" rows afterwards. Did aynone came up wit a more elegant LabTalk way?

Best regards
B. Przybyla
2   L A T E S T    R E P L I E S    (Newest First)
BPrzybyla Posted - 10/07/2013 : 03:07:05 AM
quote:
Originally posted by Penn

Hi B.Przybyla,

You can try the vfind X-Function. And the second loop in your script can be replaced by using the following script.

range rwA1 = [%B]DATA_ALL!1;  // first column in data_all sheet
range rwM1 = [%B]MERGE!1;  // first column in merge sheet
dataset ds;  // dataset for holding the indices of all found elements
vfind ix:=rwM1 value:=rwA1[ii] ox:=ds;  // find elements whose values are equal to a specified value
if(ds.GetSize() > 0)  // if size of dataset is bigger than 0
	match=1;



Penn



Works like a charm, thank you!

Best regards,
B. Przybyla
Penn Posted - 09/30/2013 : 06:21:52 AM
Hi B.Przybyla,

You can try the vfind X-Function. And the second loop in your script can be replaced by using the following script.

range rwA1 = [%B]DATA_ALL!1;  // first column in data_all sheet
range rwM1 = [%B]MERGE!1;  // first column in merge sheet
dataset ds;  // dataset for holding the indices of all found elements
vfind ix:=rwM1 value:=rwA1[ii] ox:=ds;  // find elements whose values are equal to a specified value
if(ds.GetSize() > 0)  // if size of dataset is bigger than 0
	match=1;



Penn

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