Re: Question about structure I/O in IDL [message #11095] |
Sat, 14 March 1998 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Marcus E Engdahl (mengdahl@alpha.hut.fi) writes:
> I read my data from ASCII-files using READ_ASCII which uses templates to
> define the format of the ASCII-file. The templates are structures created
> by ASCII_TEMPLATE. Since most of my ASCII-files have the same format, I'd
> like to store these structures into disk. How do I do this?
>
> Is this the right way to store it?
>
> template = ASCII_TEMPLATE(cohfilename)
> OPENW,1,'template,file'
> WRITEU,1,template
> CLOSE,1
>
> Storing seems to work alright but when I try to read the structure using
> READU I run into problems (template doesn't become a structure).
>
> OPENR,1,'template.file'
> READU,1,template
> CLOSE,1
>
> What is the correct way to store and retrieve structures?
In this situation, I think the easiest thing to do would
be to use the SAVE and RESTORE commands to save the file
template. The code might look like this:
template = ASCII_TEMPLATE(filename)
Save, template, File='template.sav'
When you want it again:
Restore, 'template.sav'
data = Read_ASCII('newfilename', Template=template)
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|