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
 Deleting Multiple alternate 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

sktbiophy

USA
3 Posts

Posted - 05/26/2009 :  4:49:04 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear Experts,

I have a worksheet with 1000 or more number of rows, and alternate rows are not required. Could you please help me to write a program that can delete the alternate rows in a worksheet. It will be a great help.
I am new to programming stuff. So please explain in details.

I am using origin 8 (windows XP)
Thank You very much

SKT

cpyang

USA
1406 Posts

Posted - 05/26/2009 :  5:27:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I don't think there is a LabTalk solution to this but you can use the following Origin C code and call it from labTalk.


void del_alternate_rows(BOOL nUndo = 1)
{
    Worksheet wks = Project.ActiveLayer();
    
    int nRows = wks.GetNumRows();
    // generate array of row index to delete
    // alternate rows, so (0-offset) 1,3,5,7,..
    if(nRows > 0)
    {
        vector<int> nvAlternateRows;
        nvAlternateRows.Data(1, nRows-1, 2);
        wks.SetSelectedRange( nvAlternateRows );
        wks.DeleteSelection( nUndo );
    }
    else
        printf("empty worksheete, not enough rows to delete");
}



CP
Go to Top of Page

easwar

USA
1965 Posts

Posted - 05/26/2009 :  5:35:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi SKT,

There is an LT example on deleting rows and cols in the Quick Help section of the help file, here is a reference for the online page:
http://originlab.com/www/helponline/Origin8/en/Quickhelp/QuickHelp/How_do_I_delete_every_nth_row_or_column_from_my_worksheet.html

Script could be slow when many rows/cols involved, and then OC solution would be faster/better.

Easwar
OriginLab
Go to Top of Page

sktbiophy

USA
3 Posts

Posted - 05/26/2009 :  6:56:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot for such quick reply, I am going to use this.

Thank You very much
SKT
quote:
Originally posted by cpyang

I don't think there is a LabTalk solution to this but you can use the following Origin C code and call it from labTalk.


void del_alternate_rows(BOOL nUndo = 1)
{
    Worksheet wks = Project.ActiveLayer();
    
    int nRows = wks.GetNumRows();
    // generate array of row index to delete
    // alternate rows, so (0-offset) 1,3,5,7,..
    if(nRows > 0)
    {
        vector<int> nvAlternateRows;
        nvAlternateRows.Data(1, nRows-1, 2);
        wks.SetSelectedRange( nvAlternateRows );
        wks.DeleteSelection( nUndo );
    }
    else
        printf("empty worksheete, not enough rows to delete");
}



CP


Go to Top of Page

sktbiophy

USA
3 Posts

Posted - 05/26/2009 :  7:00:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar,
Thanks a lot for your reply, it works fine. I am going to try OC and see, it may be faster as you have suggested.

Thank You very much
SKT


quote:
Originally posted by easwar

Hi SKT,

There is an LT example on deleting rows and cols in the Quick Help section of the help file, here is a reference for the online page:
http://originlab.com/www/helponline/Origin8/en/Quickhelp/QuickHelp/How_do_I_delete_every_nth_row_or_column_from_my_worksheet.html

Script could be slow when many rows/cols involved, and then OC solution would be faster/better.

Easwar
OriginLab

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