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
 Origin Forum
 issue in simple for loop

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
mwambach Posted - 08/23/2016 : 1:12:52 PM
Hi there!

I wrote a simple script in Labtalk to delete rows with no value in Col(C). Unfortunately when I run it in the script window, only every other empty row is deleted. What's the error in the script? Cheers!

a=1;
for (i=1;i<=1000;i++)
{
if (Col(C)[a]==0/0)
{
wks.deleteRows(a);
}
a=a++;
}
3   L A T E S T    R E P L I E S    (Newest First)
snowli Posted - 08/23/2016 : 4:09:51 PM
You are welcome.

Thanks, Snow
mwambach Posted - 08/23/2016 : 2:51:44 PM
Hi Snow!

Thanks for your help!
snowli Posted - 08/23/2016 : 2:37:36 PM
Hello, this is because after you run wks.deleteRows(a) once, the row is already shifted upwards so the row indexing is updated.

E.g. if there are some missing values in row 10, 11, 12, 13.
after deleting row 10, the old row 11, 12, 13 are row 10, 11, 12 now.

So instead of looping from 1 on, try loop of end of rows.

for (i=wks.nrows;i>=1;i--)
{
if (Col(C)[i]==0/0)
{
wks.deleteRows(i);
}
}


Thanks, Snow

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