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

Home » Public Forums » archive » Re: IDL input 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: IDL input files. [message #54527 is a reply to message #54525] Mon, 18 June 2007 11:41 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
ryanselk@gmail.com wrote:
> ive been reading some manuals and books for IDL but im not sure how to
> solve this likely simple problem.
>
> I have this I need to input to idl (.txt file):
>
> Name = {Joe}
> Department = {CS}
> Age = {25}
>
>
> and in IDL i need to save each attribute to its own variable. But if,
> lets day, department is ommited I want it to not input age as
> department. With c/c++ this isnt so bad as you can search the file for
> a 'keyword' and print the value from there, but I cant find how to do
> this in IDL.

Well, I don't think you can search the file in IDL, but you can read it in line by line
and search the lines. Why not create the file as IDL commands? e.g.:

pro test

; Create file to read
openw, lun, 'test.input', /get_lun
printf, lun, 'Name = "Joe"'
printf, lun, 'Department = "CS"'
printf, lun, 'Age = 25'
free_lun, lun

; Now read the file
openr, lun, 'test.input', /get_lun
buffer = ' '
while not eof(lun) do begin
readf, lun, buffer
result = execute(buffer)
endwhile
free_lun, lun
help, name, department, age

end

??


IDL> .run test
% Compiled module: TEST.
IDL> test
NAME STRING = 'Joe'
DEPARTMENT STRING = 'CS'
AGE INT = 25

IDL> $more test.input
Name = "Joe"
Department = "CS"
Age = 25


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: how get data from iSurface
Next Topic: Re: FSC_color and loadct clashing

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

Current Time: Fri Oct 10 15:02:34 PDT 2025

Total time taken to generate the page: 0.56015 seconds