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
 use variables instead of sheet or book

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
J.S.Schulte Posted - 08/02/2010 : 4:55:47 PM
Origin Ver. and Service Release (Select Help-->About Origin): Origin Pro 8.1 SR3
Operating System: Windows 7

Hello,

I am looking for a way to replace output destinations in several labtalk commands by a variable.

Example:
//part of a script
a=5;
b=85;
c=1;
d=1;
loop(ii,1,10)
{
wrcopy iw:=[book1]sheet1! c1:=2 r1:=a r2:=b ow:=[book1]sheet2! dc:=c dr:=d;
a=a+80;
b=b+80;
c=c+1;
}

I use this part of my script to seperate a repetitive signal into different columns. Now I want to replace the input and/or output destinations (book1, sheet1, sheet2) by variables. This would give me the opportunity to vary the destinations in a loop without repeating the whole part again and again.
I have the same problem/question regarding the copydata command. Is there a way using irng:= orng:= with variables instead of defined book or sheet destinations.

Thank you for any help!
2   L A T E S T    R E P L I E S    (Newest First)
J.S.Schulte Posted - 08/25/2010 : 06:00:33 AM
Thank you very much!!!
Penn Posted - 08/02/2010 : 11:06:01 PM
Hi,

You can use the string variable to change the input and/or output destinations. Please pay attention to the substitution notation. For example:

a=5;
b=85;
c=1;
d=1;
// define string variables for input/output
string bookSource;
string sheetSource;
string bookDestination;
string sheetDestination;
bookSource$ = "book1";
sheetSource$ = "sheet1";
bookDestination$ = "book1";
sheetDestination$ = "sheet2";
loop(ii,1,10)
{
	wrcopy iw:=[bookSource$]sheetSource$! c1:=2 r1:=a r2:=b ow:=[bookDestination$]sheetDestination$! dc:=c dr:=d;
	a=a+80;
	b=b+80;
	c=c+1;

	// here just change the output to different sheet
	sheetDestination$ = "sheet$(ii+2)";  // $(ii+2), $() substitution
}

You can use the same way in copydata command.

string strInput;
string strOutput;
strInput$ = [book1]sheet1!col(1);
strOutput$ = [book1]sheet3!col(1);
loop(ii, 1, 5)
{
	copydata irng:=strInput$ orng:=strOutput$;
	strInput$ = [book1]sheet1!col($(ii+1));
	strOutput$ = [book1]sheet3!col($(ii+1));
}


Penn

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