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
 loop of (Import - plot to one graph)

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
MikeK Posted - 05/04/2014 : 2:27:02 PM
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!;
}
2   L A T E S T    R E P L I E S    (Newest First)
MikeK Posted - 05/05/2014 : 11:11:12 AM
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
	}
}

MikeK Posted - 05/05/2014 : 05:48:15 AM
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!;

}

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