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

Home » Public Forums » archive » putting .txt files in a 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: putting .txt files in a structure [message #91693 is a reply to message #91685] Thu, 13 August 2015 07:05 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

On 08/13/15 01:57, Michael Galloy wrote:
> Do you mean you want to have the full text of the file as a string in
> your structure?

Oh. I though he wanted the file text parsed into tags:values. E.g. if
the file text was something like:

parameter1 3.14159
threshold2 2.71828

then the resulting structure (using IDL definition) would look something
like

text = {parameter1 : 3.14159, $
threshold2 : 2.71828}

and then, via something like:

text = read_myfile("readme.txt")

you could then do

btstruc = {mm: momentmm,$
ros: btstruc.ros, $
readme: text}

and then

IDL> help, btstruc.readme
** Structure <df05a8>, 2 tags, length=8, data length=8, refs=3:
PARAMETER1 FLOAT 3.14159
THRESHOLD2 FLOAT 2.71828

>
> If so, it's not so bad:
>
> nlines = file_lines(filename)
> lines = strarr(nlines)
> openr, lun, filename, /get_lun
> readf, lun, lines
> free_lun, lun
>
> cr = string([10B]) ; string([13B, 10B]) on Windows
> text = strjoin(lines, cr)
>
> If you have my library, it's just:
>
> text = mg_strmerge(mg_file(filename, /readf))
>
> Then:
>
> btstruc = {mm: momentmm,$
> ros: btstruc.ros, $
> readme: text}

But, yes, now I see this may be what he meant (and much simpler).

cheers,

paulv

p.s. Some days I always get the answer for "What colour is General
MacArthur's white horse?" wrong.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: No 8.4.1 or 8.5 release announcement
Next Topic: python bug??

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

Current Time: Wed Oct 08 14:07:56 PDT 2025

Total time taken to generate the page: 0.00239 seconds