comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » reading file into structure?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: reading file into structure? [message #24823 is a reply to message #24822] Wed, 18 April 2001 06:41 Go to previous message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
Appending to my previous query, a quick work-around seems to be to read
the file into an array and then define data.values to point to the
array. This seems a little dirty?

i.e.

pro testread, file, data
sgas = '*TEST'
l = STRLEN(sgas)
OPENR, 1, file
header = '!'
nlev = 0

WHILE STRMID(header,0,1) EQ '!' DO READF, 1, header
READS, header, nlev

array = fltarr(nlev)
data = {basic_struct, comment: ' ', values: fltarr(nlev)}

WHILE STRMID(header,0,l) NE sgas DO BEGIN
READF, 1, header
IF STRLEN(header) LT l THEN header = header + ' '
header = STRUPCASE(header)
ENDWHILE
READF, 1, array
data.values = array ; <-- dirty cheat
CLOSE, 1
END


> pro testread, file, data
> sgas = '*TEST'
> l = STRLEN(sgas)
> OPENR, 1, file
> header = '!'
> nlev = 0
>
> WHILE STRMID(header,0,1) EQ '!' DO READF, 1, header
> READS, header, nlev
>
> ;data = fltarr(nlev) ;change comments if testing array
> data = {basic_struct, comment: ' ', values: fltarr(nlev)}
>
> WHILE STRMID(header,0,l) NE sgas DO BEGIN
> READF, 1, header
> IF STRLEN(header) LT l THEN header = header + ' '
> header = STRUPCASE(header)
> ENDWHILE
> ;READF, 1, data ;<-- this works.
> READF, 1, data.values ;<-- why doesn't this work?
> CLOSE, 1
> END

[snip]
[Message index]
 
Read Message
Read Message
Previous Topic: Re: something like perl's 'require 5.4'
Next Topic: Setting up offsets array ...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 05:37:56 PDT 2025

Total time taken to generate the page: 1.03906 seconds