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
 using header variables

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
OndrejMM 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 ..;

}
2   L A T E S T    R E P L I E S    (Newest First)
Deanna Posted - 08/18/2008 : 04:04:18 AM
Thank you for sharing.

Deanna
OriginLab Technical Services
OndrejMM 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 ..;

}

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