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

Home » Public Forums » archive » Re: Is there a way to use C++ code in IDL
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: Is there a way to use C++ code in IDL [message #34193] Thu, 20 February 2003 12:07 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Here is a pile of bad code for you :)

I wrote a file parser for some home grown tagged data files we have around
here. This is the gist of it altered for your file format. It is ugly but
should get you well on your way.

I still think you should do this as a dlm but this exercise will be a good
intro to IDL. Note that I have left a lot out and I make no claims that
this is the way anyone should do this.

Enjoy.

-Rick


datasets = ''
nsets = 0

;read in the batch file
openr, lun, filename, /get_lun

while not eof(lun) do begin
line = ''
readf, lun, line

;remove comments and whitespace
temp = strsplit(line, '//', /extract)
line = strtrim(temp[0],2)

;check if this is a datablock tag
dblock = strsplit(line, ':', /extract)

if (N_ELEMENTS(dblock eq 1) then begin
;not a datablock tag
case line of

'[System]':begin

while (line ne '[End]') do begin

line=''
readf, lun, line

;remove comments and whitespace
temp = strsplit(line, '//', /extract)
line = strtrim(temp[0],2)

;parse the line of text for the keyword/param pair
kwpair = strsplit(strcompress(line, /remove_all), $
'=', /extract)
keyword = kwpair[0]

case keyword of
'Name':name = FIX(kwpair[1])
else: ;skip everything else
endcase
endwhile
end

'[Data Sets]':begin
while (line ne '[End]') do begin

line=''
readf, lun, line

;remove comments and whitespace
line = strtrim((strsplit(line, '//', /extract))[0],2)

datasets = [datasets,line]
nsets = nsets + 1
endwhile
end

'[File Attributes]':begin

while (line ne '[End]') do begin

line=''
readf, lun, line

;remove comments and whitespace
line = strtrim((strsplit(line, '//', /extract))[0],2)

case line of
'[Conditions File]':begin
while (line ne '[End]') do begin
line=''
readf, lun, line

;remove comments and whitespace
line = strtrim((strsplit(line, '//', $
/extract))[0],2)

case line of
'[Properties]':begin
while (line ne '[End]') do begin
line=''
readf, lun, line

;remove comments and whitespace
line = strtrim((strsplit(line,
'//', $
/extract))[0],2)

;process keyword/data pairs

endwhile
end
'[Frame Information]':begin

end
endcase
endwhile
end
'[Saved File]':begin

end
else:;skip everything else

endcase
endwhile
end

else:;ignore everything else
endcase

endif else begin
;This is a datablock tag

;dblock[1] will be the dataset label

endelse


endwhile

free_lun, lun
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: howto bind shortcut key to button
Next Topic: Check if coordinate is in array

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

Current Time: Sat Oct 11 03:17:04 PDT 2025

Total time taken to generate the page: 2.07435 seconds