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
 newsheet !OK in script but OK in command wind
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jmbeaujour

USA
5 Posts

Posted - 11/10/2013 :  8:58:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.6
Operating System: winXP

Hi,
here is my code. It prompts to a folder, import all files with given extention and place them in folder with name=name of the file, and finally make a plot for each file.
Now, I am trying to add a newsheet to each wrksheet (start at line comment: " //begin new lines ". But it does not work. I get a "Command Error" line.
I tried doing that with the command prompt (i.e will run the script without the addes lines) and then run the added lines with command prompt. and that works soI am not sure where I get it wrong:
Below is the code:
>>
dlgpath;


// Find all files and count how many there are
findfiles ext:="*.svd";
int numFiles = fname.GetNumTokens(LF);

// Loop over all files
int nFirst = 1;
for(int ifile = 1; ifile <= numFiles; ifile++)
{
string filepath$, filename$, subFolderPath$;

// Get next file name
filepath$=fname.gettoken(ifile,LF)$;
subFolderPath$ = filepath$+"/0_"+ifile;
// Parse out just file name without path and without extension
filename$ = filepath.GetFileName(1)$;

// Make a new PE subfolder using the file name and set it active
pe_mkdir filename$ cd:=1;

// Add a new book and import data file
// Filter for file import PL Loop Analyis SVD Loop is in user folder
// The filter imports the data columns with appropriate names and X or Y settings
newbook;
impfile fname:=filepath$ filtername:="ImportSVDFile.oif" location:=user;

// Remember Book and Sheet names
string bkname$ = page.name$;
string shname$ = layer.name$;
//Activate the worksheet of imported data
page.active$= shname$;
plotxy iy:=(1,3) plot:=200 ogl:=[<new template:=PKLoop-SingleSVD>];

// Make top X label the filename
label -s -xt %(filename$);


//Name window after filename
page.label$ = filename$;

//begin new lines
page.active$= bkname$; // Active worksheet by name
newsheet;
//end new lines

// Set PE folder to previous level and go to next file
pe_cd ..;
};

>>

Thanks for suggestions/comments

greg

USA
1379 Posts

Posted - 11/11/2013 :  12:17:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The active method of the page object tells the page which layer should be active. Your current page is the graph so the bkname$ will fail.

Make the correct page active:
win -a %(bkname$); // %() notation needed by old LabTalk commands

then you can make any layer active:
page.active$ = shname$;

(The book probably only has one sheet/layer so the second command may not be needed.)

P.S. Not sure what this was supposed to do:
subFolderPath$ = filepath$+"/0_"+ifile;
but it isn't used so the error can be ignored.

Edited by - greg on 11/11/2013 12:25:48 PM
Go to Top of Page

jmbeaujour

USA
5 Posts

Posted - 11/11/2013 :  2:02:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks.
It works.
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