T O P I C R E V I E W |
lillt91 |
Posted - 02/22/2018 : 04:07:52 AM 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]; } }
|
2 L A T E S T R E P L I E S (Newest First) |
lillt91 |
Posted - 02/23/2018 : 05:05:08 AM 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
|
Hideo Fujii |
Posted - 02/22/2018 : 10:07:57 AM 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 |
|
|