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
 Looping over Worksheets with Labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Filia Prima

Germany
1 Posts

Posted - 03/02/2018 :  06:34:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

yuki_wu

896 Posts

Posted - 03/05/2018 :  02:25:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am not sure if I understand your question fully, but you could try to comment this line:

//page.active = isheet;

then run the script once again to see if you get the result you desired.

Regards,
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