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
 Copy rows...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Ana-Maria

USA
4 Posts

Posted - 05/24/2010 :  3:43:19 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,
I am trying to write a labtalk to copy all rows of the original worksheet to a new worksheet. From row 1 to last row, but row 1, 2, 3, last, should be repeated a number of times (30 times for example) in the new worksheet (same number of repetition for all the rows). I only have 3 columns, but a big number of rows.

I am using Origin Version 7.5 and Windows Vista.
Thanks,
Ana.


Penn

China
644 Posts

Posted - 05/25/2010 :  01:27:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ana,

You can use the copy command. Please try the following script:

// suppose the name of original worksheet is Data1,
// name of the new worksheet is Data2.
// 3 columns are column A, B and C.
for(ii=1; ii<=30; ii++)
{
	copy -a Data1_A Data2_A;
	copy -a Data1_B Data2_B;
	copy -a Data1_C Data2_C;
}


Penn
Go to Top of Page

Ana-Maria

USA
4 Posts

Posted - 05/25/2010 :  7:22:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn! Thanks!
I was using copy already, but I can not do what I need If I have:
1 1 1
2 2 2
3 3 3
I would like to repeat a number of times as I explain before, but I need them to be like this:
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
3 3 3
This is what I am not able to do

Go to Top of Page

Penn

China
644 Posts

Posted - 05/25/2010 :  10:14:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ana,

Sorry for misunderstanding your requirement. However, the copy can still be used to solve your problem. Please try the following script.

set data2 -er 30*(data1!wks.maxrows);  // set row size of Data2 worksheet
for(jj=1; jj<=data1!wks.maxrows; jj++)
{
	for(ii=(jj-1)*30+1; ii<=30*jj; ii++)
	{
		// use -b and -e options to copy only one cell
		copy -b jj data1_a data2_a -b ii -e ii;
		copy -b jj data1_b data2_b -b ii -e ii;
		copy -b jj data1_c data2_c -b ii -e ii;
	}
}


Penn
Go to Top of Page

Ana-Maria

USA
4 Posts

Posted - 05/25/2010 :  11:51:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Penn,
It is exactly what I was trying to do...
Thanks a lot Penn! :-)

Sincerely,
Ana.
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