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
 Extracting Header Information

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
rmtruji Posted - 11/06/2003 : 4:32:36 PM
I am having trouble extracting header information from a worksheet so that I can then plot the data. I have the following code that plots 3 datasets into one graph, but the code won't extract the header information into a separate file. Any suggestions out there?



***********************************
ii=1;
%B= (Plot3) (Plot4) (Plot5);
getn (Template) ii:B (Please Choose Plot Type:);
fdlog.openpath(); //allow user to specify a path

switch(ii){
case 1:
run.section(,plot3);
break;
case 2:
run.section(,plot4);
break;
case 3:
run.section(,plot5);
break;

}

[plot3]

%Z=Mag_X Mag_Y Mag_Z Rate_X Rate_Y Rate_Z Acc_X Acc_Y Acc_Z XMTSUPV XMTSUPI XMTP5V;
loop(ii,1,12)
{


win -t data; //create new worksheet for the next data file
open -w %[%Z,#ii].hta;//open into wks
%W=%H; //store the name of the wks

create H%W -w 48 Parameter Data;
wks.col1.width=40;
wks.col2.width=40;
wks.col1.format=2;
file.rewind();


rownum=1;
for (cc=48; cc > 0; cc --)
{
if (file.lread(Z,hfile))
{


%N=%[%Z,':']; //find colon and return text to left
wks.paste(N,1,rownum); //paste into worksheet column 1
%N=%[%Z,>':']; //read in part of line to right of colon
wks.paste(N,2,rownum); //paste into column 2

if (rownum == chname){%K=%N}; //store measurement name string in %K
if (rownum == measdescr){%O=%N}; //store measurement description in %O
if (rownum == yunits){%L=%N}; //store y units string in %L
if (rownum == fltnum){%Q=%N}; //store flight number in string %Q
if (rownum == dropratio){%R=%N}; //store dropout ratio in string %R
if (rownum == fltdate){%S=%N};
if (rownum == version){%T=%N};
if (rownum == toffset){%U=%N};
if (rownum == t0){%V=%N};
rownum ++;
}
else {rownum ++};
};


file.close();


if(rmod(ii,3)==1){ win -t plot "3-plot.otp"; %L=%H;}
else
win -a %L;
switch(ii){
case 1 4 7 10:
page.active=3;
layer -i %(%W,2);
layer -a;
break;

case 2 5 8 11:
page.active=2;
layer -i %(%W,2);
layer -a;
break;

case 3 6 9 12:
page.active=1;
layer -i %(%W,2);
layer -a;
break;

}

}
3   L A T E S T    R E P L I E S    (Newest First)
rmtruji Posted - 11/06/2003 : 6:53:56 PM
quote:

In Origin 6.1 or later (and possibly earlier) the header is automatically saved to the string variable %Z. So it's possible that your %Z list doesn't survive the initial import. Try another string variable,

%F=Mag_X Mag_Y Mag_Z Rate_X Rate_Y Rate_Z Acc_X Acc_Y Acc_Z XMTSUPV XMTSUPI XMTP5V;
loop(ii,1,12)
{
win -t data; //create new worksheet for the next data file
open -w %[%F,#ii].hta;//open into wks
%W=%H; //store the name of the wks
%Z=; // type header to script window
etc.

I don't know if all 48 lines of your header will fit into %Z, but if it does then it should be straightforward to extract what you need.

Hope that helps.

...Actually, you redefine %Z yourself with file.lread(Z,hfile).

...And it looks like you use FUM methods without opening the file. IOW, hfile is not defined. But you don't need FUM at all if your header is already stored in %Z.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/06/2003 5:55:01 PM

Edited by - Mike Buess on 11/06/2003 6:21:29 PM






Thank you Mike Buess. Your suggestion for changing %Z to %F worked! Thanks a bunch!
Mike Buess Posted - 11/06/2003 : 5:43:28 PM
In Origin 6.1 or later (and possibly earlier) the header is automatically saved to the string variable %Z. So it's possible that your %Z list doesn't survive the initial import. Try another string variable,

%F=Mag_X Mag_Y Mag_Z Rate_X Rate_Y Rate_Z Acc_X Acc_Y Acc_Z XMTSUPV XMTSUPI XMTP5V;
loop(ii,1,12)
{
win -t data; //create new worksheet for the next data file
open -w %[%F,#ii].hta;//open into wks
%W=%H; //store the name of the wks
%Z=; // type header to script window
etc.

I don't know if all 48 lines of your header will fit into %Z, but if it does then it should be straightforward to extract what you need.

Hope that helps.

...Actually, you redefine %Z yourself with file.lread(Z,hfile).

...And it looks like you use FUM methods without opening the file. IOW, hfile is not defined. But you don't need FUM at all if your header is already stored in %Z.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/06/2003 5:55:01 PM

Edited by - Mike Buess on 11/06/2003 6:21:29 PM
rlewis Posted - 11/06/2003 : 5:33:08 PM
I reviewing your LabTalk code ....

if (rownum == chname){%K=%N}; //store measurement name string in %K
if (rownum == measdescr){%O=%N}; //store measurement description in %O
if (rownum == yunits){%L=%N}; //store y units string in %L
if (rownum == fltnum){%Q=%N}; //store flight number in string %Q
if (rownum == dropratio){%R=%N}; //store dropout ratio in string %R
if (rownum == fltdate){%S=%N};
if (rownum == version){%T=%N};
if (rownum == toffset){%U=%N};
if (rownum == t0){%V=%N};

I cant find anywhere where the variables "chname", "measdescr" "fltnum" ... etc are defined and/or initialized. Can that be the problem ??

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