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
 Origin Forum
 loop over worksheets won't work
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

lillt91

Germany
14 Posts

Posted - 02/22/2018 :  04:07:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 15
Operating System: windows 7

hi, in my folder are the worksheets "A1000", "A2375", ... "A13625" and the last one is Book1 with the tansposed raw data. I tried to loop over all work worksheets except book1. So this is my script:

quote:
//Spalten hinzufügen
doc -e LB //Loop over each worksheet
{
if(%H == "Book1")
{ continue; };
if(%H == "Book10")
{ continue; };

//X-Werte und so weiter
vglm1=200; vglm2=200; vglm3=200; vglm4=200;

loop(ii, 1, 56)
{
cc=ii*4-2;

limit wcol(cc); //Maximum jeder Spalte ausgeben lassen
bb=limit.imax;
wcol(cc+1)[3] = wcol(1)[bb];
wcol(cc+2)[3] = limit.ymax;

loop(row, 1, bb-1) //Linke Seite der Temperaturkurve
{
vgl1=abs(col($(cc))[row]-1050);
if(vgl1 < vglm1)
{
vglm1=vgl1;
min1=row;
}

vgl2=abs(col($(cc))[row]-1150);
if(vgl2 < vglm2)
{
vglm2=vgl2;
min2=row;
}
}
wcol(cc+1)[1]=col(1)[min1]; wcol(cc+2)[1]=wcol(cc)[min1];
wcol(cc+1)[2]=col(1)[min2]; wcol(cc+2)[2]=wcol(cc)[min2];

loop(row, bb+1, 154) //Rechte Seite der Temperaturkurve
{
vgl3=abs(col($(cc))[row]-1150);
if(vgl3 < vglm3)
{
vglm3=vgl3;
min3=row;
}

vgl4=abs(col($(cc))[row]-1050);
if(vgl4 < vglm4)
{
vglm4=vgl4;
min4=row;
}
}
wcol(cc+1)[4]=col(1)[min3]; wcol(cc+2)[4]=wcol(cc)[min3];
wcol(cc+1)[5]=col(1)[min4]; wcol(cc+2)[5]=wcol(cc)[min4];
}
}



Edited by - lillt91 on 02/23/2018 05:59:24 AM

Hideo Fujii

USA
1582 Posts

Posted - 02/22/2018 :  10:07:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi lillt91,

Though I haven't looked your code deep inside, it seems you need to use Continue; instead of
Break; when the loop detected Book1; Otherwise once it comes to Book1, the loop would finish.
https://www.originlab.com/doc/LabTalk/ref/Continue-cmd

Hope I didn't miss the point.

--Hideo Fujii
OriginLab
Go to Top of Page

lillt91

Germany
14 Posts

Posted - 02/23/2018 :  05:05:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Seems like it doesnt work for loops so we changed the loop into for-loops. Now it works!

quote:
doc -e LB //Loop over each worksheet
{
if(%H == "Book1" || %H == "Book10")
{ continue; };

for (int ii=1; ii<56; ii++)
{
//X-Werte und so weiter
vglm1=200; vglm2=200; vglm3=200; vglm4=200;
int cc=1; double bb=1;

cc=ii*4-2;

limit wcol(cc); //Maximum jeder Spalte ausgeben lassen
bb=limit.imax;
wcol(cc+1)[3] = wcol(1)[bb];
wcol(cc+2)[3] = limit.ymax;


for (int row=1; row<bb-1; row++) //Linke Seite der Temperaturkurve
{
vgl1=abs(col($(cc))[row]-1050);
if(vgl1 < vglm1)
{
vglm1=vgl1;
min1=row;
}

vgl2=abs(col($(cc))[row]-1150);
if(vgl2 < vglm2)
{
vglm2=vgl2;
min2=row;
}
}
wcol(cc+1)[1]=col(1)[min1]; wcol(cc+2)[1]=wcol(cc)[min1];
wcol(cc+1)[2]=col(1)[min2]; wcol(cc+2)[2]=wcol(cc)[min2];

for (int row=bb+1; row<154; row++) //Rechte Seite der Temperaturkurve
{
vgl3=abs(col($(cc))[row]-1150);
if(vgl3 < vglm3)
{
vglm3=vgl3;
min3=row;
}

vgl4=abs(col($(cc))[row]-1050);
if(vgl4 < vglm4)
{
vglm4=vgl4;
min4=row;
}
}
wcol(cc+1)[4]=col(1)[min3]; wcol(cc+2)[4]=wcol(cc)[min3];
wcol(cc+1)[5]=col(1)[min4]; wcol(cc+2)[5]=wcol(cc)[min4];
}
}
- r 0


Edited by - lillt91 on 02/23/2018 09:59:13 AM
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