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

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
sktbiophy Posted - 05/26/2009 : 4:49:04 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
sktbiophy Posted - 05/26/2009 : 7:00:07 PM
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

sktbiophy Posted - 05/26/2009 : 6:56:43 PM
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


easwar Posted - 05/26/2009 : 5:35:56 PM
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
cpyang Posted - 05/26/2009 : 5:27:35 PM
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

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