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
 loop issue - stops working after cycle 8
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Quentin

France
1 Posts

Posted - 08/08/2016 :  11:26:15 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello everyone,

I'm having a strange issue with one of my Labtalk program.

It's a loop over multiple sheets A1, A2, A3...Ahalfcyclenumber.
In every of these sheets they are three columns. If the column Ima is positive then I transform an other column - the first one - with the constant "capa". Capa is actually define on sheets where Ima is negative. Capa is the last value of the 1 column for Ima negative sheets.
( negative and positive sheets alternate)

however, it works fine until cycle 8. Then " capa = col(1)[numpoints]" it's always done considering the col(1) of the A8 sheet... I don't understand why. Anyone has an idea ?

here is the code.

loop(ii, 0, halfcyclenumber)
{ page.active$=A$(ii);
if ( col(Ima)[5]>0 )
{ mathtool iy1:=(col(1)) operator:=sub operand:=const const:=capa;
mathtool iy1:=(col(1)) operator:=mul operan:=const const:=-1;
}
else
{
if (col(Ima)[5]<0)
{
numpoints = wks.nrows;
capa = col(1)[numpoints];
}
else
{
}
};

Quentin

yuki_wu

896 Posts

Posted - 08/08/2016 :  11:09:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I think you’d better figure out how many worksheets in your workbook at first. Try the scripts below and make sure that there are more than 8 worksheets in your workbook.

Loop (num,1,page.nlayers)   
{
      type "layer number $(num)";
};

On the other hand, I don’t think the loop can start from 0 as your description. You may change it from 1 to halfcyclenumber if you want the loop over sheets A1, A2, A3...Ahalfcyclenumber.

In fact, Origin provides various tools to help you to debug your LabTalk scripts. I think you can find a way to debug your code on this page:
http://www.originlab.com/doc/LabTalk/Tutorials/Tutorial-Debug

Hope it helps.

Yuki
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