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
 use variables instead of sheet or book
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

J.S.Schulte

Germany
11 Posts

Posted - 08/02/2010 :  4:55:47 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

Penn

China
644 Posts

Posted - 08/02/2010 :  11:06:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

J.S.Schulte

Germany
11 Posts

Posted - 08/25/2010 :  06:00:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much!!!
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