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
 Forum for Origin C
 Delete Every Second Row
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

masterd

Australia
Posts

Posted - 09/03/2008 :  02:49:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version: 7.5 SR6
Operating System: XP

What is the easiest way of deleting every second row (2nd, 4th, 6th, etc.) in the active worksheet? A script would be preferred so I can include it into my 'File Size Reduction Script'.

Cheers,

Darko

MisterSpock

1 Posts

Posted - 09/05/2008 :  05:28:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Darko,
you can try this code:


void deleteRow()
{
	Worksheet wks = Project.ActiveLayer();
	if(NULL==wks)
		return;				// no active window, or not a worksheet
	int rowNumber, rowCount, firstCol;
	rowNumber = wks.GetNumCols();	//number of rows in aktive worksheet
	rowCount = 3;			// for every third "rowCount = 3" and so on
	firstCol = 0;			// the first row to delete
	int jj = 0;
	for( int ii = 1; ii <= ((rowNumber - firstCol + rowCount) / rowCount); ii++ )
	{
		wks.DeleteCol(firstCol + jj);
		jj=jj+rowCount - 1;
	}
}
Go to Top of Page

masterd

Australia
Posts

Posted - 09/08/2008 :  01:28:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi MisterSpock,

Your code acatually deletes columns instead of the rows. It was a slight tweak of your code that enables me to delete rows now.

Thanks again.


void delrow()
{
Worksheet wks = Project.ActiveLayer();
if(NULL==wks)
return; // no active window, or not a worksheet
waitCursor wCur; // Bring up wait cursor to indicate computation in progress
int rowNumber, rowCount, firstRow;
rowNumber = wks.GetNumRows(); //number of rows in aktive worksheet
rowCount = 2; // for every third "rowCount = 3" and so on
firstRow = 1; // the first row to delete
int jj = 0;
for( int ii = 1; ii <= ((rowNumber - firstRow + rowCount) / rowCount); ii++ )
{
wks.DeleteRow(firstRow + jj);
jj=jj+rowCount - 1;
}
}
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