[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: template for READ_ASCII



Mark,
Thanks. Only change I had to make was adding an "endcase"  before the
"endif"  ... without it I got the "end of file before end or program" error.

It works great. I just didn't know how to save a structure. Now I do.
This is an incredible group --- answers to your problems while you wait.
Bob

> From: m.hadfield@niwa.cri.nz (Mark Hadfield)
> Organization: Mailgate.ORG Server - http://www.Mailgate.ORG
> Newsgroups: comp.lang.idl-pvwave
> Date: Mon, 25 Jun 2001 02:23:35 +0000 (UTC)
> Subject: Re: template for READ_ASCII
> 
> From: "Bob Fugate" <rqfugate@mindspring.com>
> 
>> My question is, can I save the template somehow so I don't have to
>> regenerate it with ASCII_TEMPLATE each time I restart IDL and  want to
> read
>> new tables? I realize I only have to run ASCII_TEMPLATE once each session
>> but I would like to make this completely automatic and so I don't have to
>> manually go through the GUI each day. It is not a really big deal but I am
>> getting greedy.
> 
> The template is an IDL structure. You can save it to disk with SAVE and
> restore it with RESTORE.
> 
> Here's how I would do it:
> 
> function read_myfile, file
> common myblock, template
> if n_elements(template) eq 0 then begin
> template_file = <specify your template file name here>
> case file_test(template_file, /READ) of
> 0: begin
> template = ascii_template(file)
> save, FILENAME=template_file
> end
> 1: restore, FILENAME=template_file
> endif
> return, read_ascii(file, TEMPLATE=template)
> end
> 
> ---
> Mark Hadfield
> m.hadfield@niwa.cri.nz  http://katipo.niwa.cri.nz/~hadfield
> National Institute for Water and Atmospheric Research
> 
> 
> 
> -- 
> Posted from clam.niwa.cri.nz [202.36.29.1]
> via Mailgate.ORG Server - http://www.Mailgate.ORG