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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Looping over Worksheets with Labtalk

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Filia Prima Posted - 03/02/2018 : 06:34:14 AM
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!
1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 03/05/2018 : 02:25:36 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000