Origin Ver.: Origin 2017
Operating System: Windows 7
Hi,
I am a beginner in using LabTalk.
I want to loop over existing worksheets in different workbooks and perform some operation on them. I am aware that I can probably solve my problem by using the "doc -e LB" command, but for now, I tried the following script:
newbook "Results" option:=lsname result:=ResultBkName$ chkname:=1;
doc -ef W
{
string TempBkName$=page.name$;
string TempBkLongName$=page.longname$;
if (TempBkName.Match("*result*")==0)
{
newsheet book:=ResultBkName$ name:="Res_"+TempBkLongName$ outname:=MyShtName$ cols:=5 labels:="Measurement|G'_0|Inflection Point";
newsheet book:=TempBkLongName$ name:="Slopes_"+TempBkLongName$ outname:=SlopeShtName$;
for(int isheet = 1; isheet <= page.nlayers; isheet++)
{
page.active = isheet;
//page.active$ = SlopeShtName$;
SlopeShtName$!cell(isheet,1)=isheet
};
};
}
I expected it to print each number "isheet" starting from 1 up to the number of worksheets into the new "Slope" sheet, but instead, it only prints the last number. Apparently the "page.active" command I wanted to use to perform some different operation in between produces an error. Although this is not exactly what I need for my project, I would like to understand why it doesn't work as I expected.
Am I looping in a wrong way? Do I have a typo somewhere?
I would be very happy if someone could explain this to me.
Thank you!