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

Home » Public Forums » archive » Re: Config files
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: Config files [message #47492 is a reply to message #47402] Thu, 09 February 2006 20:43 Go to previous message
Robert Barnett is currently offline  Robert Barnett
Messages: 70
Registered: May 2004
Member
Another way is to do it with structures. Just keep your settings in a
structure variable which is defined in a common block. I have included
some example code to read and write structures to/from a text file.
Mind the line feeds inserted by Google.

pro rt_textstructRead, struct, filename
print, "Reading", filename
if (N_ELEMENTS(struct) EQ 0) then return
if (~ file_test(filename, /READ)) then message, "Cannot read
text struct
ure file " + string(filename)
openr,lun1,filename,/GET_LUN
names = tag_names(struct)
pair = ''
while (not EOF(lun1)) do begin
readf, lun1, pair
hashi = strpos(pair,'#')
if (hashi GE 0) then pair = strmid(pair,0,hashi)
eqi = strpos(pair,'=')
if (eqi GE 1) then begin
name = strupcase(strtrim(strmid(pair,0,eqi),2))
for i=0,N_TAGS(struct)-1 DO BEGIN
if (names[i] EQ name) then begin
value = struct.(i)
setvalue =
strtrim(strmid(pair,eqi+1,str
len(pair)-eqi),2)
if (setvalue ne '') then begin
reads, setvalue, value
struct.(i) = value
endif
endif
endfor
endif
endwhile
free_lun, lun1
end


pro rt_textstructWrite, struct, filename
if (N_ELEMENTS(struct) EQ 0) then return
openw,lun1,filename,/GET_LUN
names = tag_names(struct)
for i=0,N_TAGS(struct)-1 DO BEGIN
printf, lun1, names[i], " = ",struct.(i)
endfor
printf, lun1
free_lun, lun1
end


Robbie
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: help with text widget...
Next Topic: Re: IDLWave documentation generation

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

Current Time: Thu Oct 09 23:04:48 PDT 2025

Total time taken to generate the page: 1.27961 seconds