| Author |
Topic  |
|
|
OndrejMM
Australia
81 Posts |
Posted - 08/14/2008 : 10:01:22 AM
|
Hi Guys,
I have written the script below, where I'm using three variables taken from the file headers (H011, H012, H013),...
Then I'm using these "header variables" in calculation
aa$ = %(,@w,H011$); bb$ = %(,@w,H012$); cc$ = %(,@w,H013$);
col(B)= %(aa$) + (%(bb$)-%(aa$)) / (%(cc$)-1) * (col(ROW)-1);
but as I load different files also the "header variables" change and really when I check "page.info.user.=" each "book" has its own "header variables" but dispite this in above calculation the same variables are used over and over,...
how can I rewrite the header variables when loading a new file? can I samehow simply fix this problem?
Many Thanks Ondrej
// Point to where the data files are
string path$ = "C:\Ondrej\";
// Find all files with wild card
findfiles ext:="*.asc"; int numFiles = fname.GetNumTokens(LF);
// Loop over all files
int nFirst = 1; for(int ifile = 1; ifile <= numFiles; ifile++)
{ string filepath$, file$; // Get next file name
filepath$=fname.gettoken(ifile,LF)$;
// Parse out just file name without path and without extension
file$ = filepath.gettoken(filepath.getnumtokens(\),\)$; file$ = file.gettoken(1,.)$; // Make a new PE subfolder and set it active pe_mkdir file$ cd:=1; // Add a new book and import data file // Apply filter newbook;
impfile fname:=filepath$ filtername:="christophe2.oif" location:=0; aa$ = %(,@ld,H011$); bb$ = %(,@ld,H012$); cc$ = %(,@ld,H013$);
//column ROW
if( !exist(%H_ROW,1)) work -i 0 ROW; //insert column ROW wks.colSel(1, 1); //select 1st column menu -e 36444; //fill column with row numbers menu -e 50110; //move column to last wks.colSel(3, 0); //deselect 3rd column
//move column X to first position
wks.colSel(1, 1); //select 1st column menu -e 50126;
col(B)= %(aa$) + (%(bb$)-%(aa$)) / (%(cc$)-1) * (col(ROW)-1);
wks.col$(colnum(A)).type=1; // make this column Y wks.col$(colnum(B)).type=4; // make this column X %W=%H; // save wks name win -t P; // create graph window lay -i202 %W_A; // plot as line+symbol lay -a; menu -e 57652; pe_cd ..;
}
|
|
|
OndrejMM
Australia
81 Posts |
Posted - 08/16/2008 : 5:41:05 PM
|
here is the final (working)script if someone is interested,...
// Point to where the data files are
string path$ = "C:\X\";
// Find all files with wild card
findfiles ext:="*.asc"; int numFiles = fname.GetNumTokens(LF);
// Loop over all files
int nFirst = 1; for(int ifile = 1; ifile <= numFiles; ifile++)
{ string filepath$, file$; // Get next file name
filepath$=fname.gettoken(ifile,LF)$; // Parse out just file name without path and without extension
file$ = filepath.gettoken(filepath.getnumtokens(\),\)$; file$ = file.gettoken(1,.)$; // Make a new PE subfolder and set it active pe_mkdir file$ cd:=1; // Add a new book and import data file // Apply filter newbook; %W=%H;
impfile fname:=filepath$ filtername:="filter_x.oif" location:=0; // delete imported file
file_delete(filepath$);
//assign header variables
aa$ = %(%W,@w,H011$); bb$ = %(%W,@w,H012$); cc$ = %(%W,@w,H013$);
//column ROW
if( !exist(%H_row,1)) work -i 0 row; //insert column ROW wks.colSel(1, 1); //select 1st column menu -e 36444; //fill column with row numbers menu -e 50110; //move column to last wks.colSel(3, 0); //deselect 3rd column
//move column X to first position
wks.colSel(1, 1); //select 1st column menu -e 50126; wks.colSel(2, 0); //deselect 2nd column
col(B)= %(aa$) + (%(bb$)-%(aa$)) / (%(cc$)-1) * (col(row)-1);
wks.col$(colnum(A)).type=1; // make this column Y wks.col$(colnum(B)).type=4; // make this column X work -n 1 axis.X; work -n 2 axis.Y; %W=%H; // save wks name doc -t graph_x.otp; // create graph window lay -i202 %W_axis.Y; // plot as line+symbol lay -a; lab -xb (axis.X [a.u.]); lab -yl (axis.Y [a.u.]);
menu -e 57652; pe_cd ..;
}
|
 |
|
|
Deanna
China
Posts |
Posted - 08/18/2008 : 04:04:18 AM
|
Thank you for sharing.
Deanna OriginLab Technical Services |
 |
|
| |
Topic  |
|
|
|