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
 Extracting Header Information
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rmtruji

USA
10 Posts

Posted - 11/06/2003 :  4:32:36 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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;

}

}

rlewis

Canada
253 Posts

Posted - 11/06/2003 :  5:33:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 ??
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/06/2003 :  5:43:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

rmtruji

USA
10 Posts

Posted - 11/06/2003 :  6:53:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
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