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
 Row row row your data gently down the script...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

BPrzybyla

Germany
6 Posts

Posted - 09/24/2013 :  08:45:23 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Edited by - BPrzybyla on 09/24/2013 08:57:36 AM

Penn

China
644 Posts

Posted - 09/30/2013 :  06:21:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

BPrzybyla

Germany
6 Posts

Posted - 10/07/2013 :  03:07:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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