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
 loop of (Import - plot to one graph)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

MikeK

6 Posts

Posted - 05/04/2014 :  2:27:02 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8 SR
Operating System: W7

Hi,

I want to import some number of ascii files, do some operations with them and plot them all to one graph - but everytime, at the second loop it is as if the plotxy function cant access correct range ( message in "script window Unknown, VarName = iy, VarValue = "). I have tried various ways of switching the active window, but none of my implementations worked. Could someone please advise me? Thank you.

dlgfile gr:=*.dat mu:=1; //select files to import
string file$, filename$;
newbook n:=Data;
loop(ii,1,fname.GetNumTokens(CRLF))
{

file$ = fname.GetToken(ii,CRLF)$;

impasc fname:=file$
options.ImpMode:=4
options.Names.FNameToSht:=0
options.Names.FNameToBk:=0;

normalize col(3);
stats col(10);
col(11) = col(10)-stats.mean + ii;
string num$ = $(ii); //convert number of current iteration to string
string shtnm$ = "Sheet" + num$; //assemble latest sheet number

plotxy [Book1]shtnm$!(2,11) plot:=200 ogl:=1!;
}

MikeK

6 Posts

Posted - 05/05/2014 :  05:48:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
So, i solved it just by plotting it explicitly to Graph1 - not so universal, but functional.

dlgfile gr:=*.dat mu:=1; //select files to import
string file$, filename$;
newbook n:=Data;
loop(ii,1,fname.GetNumTokens(CRLF))
{

file$ = fname.GetToken(ii,CRLF)$;

impasc fname:=file$
options.ImpMode:=4
options.Names.FNameToSht:=0
options.Names.FNameToBk:=0;
wks.col2.type=4;
normalize col(3);
stats col(10);
col(11) = col(10)-stats.mean + ii;
string num$ = $(ii); //convert number of current iteration to string
string shtnm$ = "Sheet" + num$; //assemble latest sheet number
window -a Book1;
plotxy [Book1]shtnm$!(2,11) plot:=200 ogl:=[Graph1]1!;

}
Go to Top of Page

MikeK

6 Posts

Posted - 05/05/2014 :  11:11:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
And hopefully final, more elegant solution :)


dlgfile gr:=*.dat mu:=1; //select files to import
string file$;
newbook;
%A = %H;						//remember book
loop(ii,1,fname.GetNumTokens(CRLF))
{

	file$ = fname.GetToken(ii,CRLF)$;		//find file

	impasc fname:=file$ 				//import file
		options.ImpMode:=4			//new sheet for each import
		options.Names.FNameToBk:=0;		//dont rename book
	window -a %A;
	wks.col2.type= 4;				//set col(2) to X
	normalize col(3);			
	stats col(10);					//make statistics of col(10)
	col(11) = col(10)-stats.mean + ii -1;	
	%A!wks.col11.label$= "Intensity/arb.u.";
	%B = page.active$;
	
	if (ii == 1){
		plotxy [%A]%B!(2,11) 
			plot:=200 			//plot as line
			legend:=0;			//don't plot the legend
		%K=%H;					//get graph name
	}
	if (ii > 1) {
		plotxy [%A]%B!(2,11) 
			plot:=200 			//plot as line
			ogl:=[%K]1! 			//plot to the same graph layer 1
			legend:=0;			//don't plot the legend
	}
}

dlgfile gr:=*.dat mu:=1; //select files to import
string file$;
newbook;
%A = %H;						//remember book
loop(ii,1,fname.GetNumTokens(CRLF))
{

	file$ = fname.GetToken(ii,CRLF)$;		//find file

	impasc fname:=file$ 				//import file
		options.ImpMode:=4			//new sheet for each import
		options.Names.FNameToSht:=1		//dont rename sheet
		options.Names.FNameToBk:=0;		//dont rename book
	window -a %A;
	wks.col2.type= 4;				//set col(2) to X
	normalize col(3);			
	stats col(10);					//make statistics of col(10)
	col(11) = col(10)-stats.mean + ii -1;	
	%A!wks.col11.label$= "Intensity/arb.u.";
	%B = page.active$;
	
	if (ii == 1){
		plotxy [%A]%B!(2,11) 
			plot:=200 			//plot as line
			legend:=0;			//don't plot the legend
		%K=%H;					//get graph name
	}
	if (ii > 1) {
		plotxy [%A]%B!(2,11) 
			plot:=200 			//plot as line
			ogl:=[%K]1! 			//plot to the same graph layer 1
			legend:=0;			//don't plot the legend
	}
}


Edited by - MikeK on 05/06/2014 06:35:16 AM
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