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
 Find the mistake
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sbaruah

Germany
Posts

Posted - 11/16/2005 :  05:56:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7
Operating System: win xp

Hi,
I am just in the learner's state. Can you tell me the mistake in the following?

I want to delete such rows from a worksheet which contain the number 2 in a particular column (say C).
Here it goes:

getnumber
(total row number) rownum;
// total row number in the main worksheet

work -d maindata;
// duplicate the worksheet and call it maindata

window -a maindata;
// set the window maindata as the active window

for(i2=1; i2<=rownum; i2=i2+1)
{
if(maindata_C[i2]==2)
{
work -s 1 $(i2) 5 $(i2);
Menu -e 36442;
//delete the whole row
}
}

Mike Buess

USA
3037 Posts

Posted - 11/16/2005 :  08:08:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Deleting a row renumbers all subsequent rows so it's better to start from the bottom and search up. This variation also uses the mark command to delete the row...

work -d maindata;
get maindata_C -e rownum; // number of rows
for(i2=rownum; i2>0; i2--)
{
if(maindata_C[i2]==2)
mark -d maindata_C -b i2 -e i2;
};

However, the following method will be much faster because it does not have to examine every row. It uses the list() function to find the next occurrence of the specified value.

work -d maindata;
for(i2=1;i2>0;i2++) {
ii=list(2,maindata_C);
if(ii==0) break;
mark -d maindata_C -b ii -e ii;
};

Mike Buess
Origin WebRing Member
Go to Top of Page

sbaruah

Germany
Posts

Posted - 11/16/2005 :  10:57:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Thanks for your suggestion. It works nicely.
Regards.
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