[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

point_lun question



Hi,
I have a data file with several measurements separated by some header
lines followed by data points. The whole file containes many
measurements. So I want to write a procedure, that reads the header and
the position of the file pointer at the end of the header and returns
this in a structure for further data processing.
Actually the routine finds the header, however, point_lun returns the
'correct' value only for the first header. If I check the second
position of the pointer using an hexditor the positions are not correct.
Whats wrong ? Do I use the wrong data type

I have added some code below:

function rd_data_header
current_line=""
count=0

filen=pickfile()
openr,unit,filen,/get_lun

while not (EOF(unit)) do begin
readf,unit,current_line
if (strpos(current_line,'#S ') eq 0) then begin
 current_pos=fstat(unit)

if (count=0) then begin
 result_header=current_line
 result_pos=current_pos.cur_ptr
 count=1
endif
if (count=1) then begin
 tmp=strarr(size(result_header,/n_elements)+1) ; increase array size
 tmp_pos=lon64arr(size(result_pos,/n_elements)+1) ; increase array size

 tmp[0:size(result_header,/n_elements)-1]=result_header ; save obtained
headers
 tmp_pos[0:size(result_pos,/n_elements)-1]=result_pos  ; save obtained
positions

 tmp[size(result_header,/n_elements)]=current_line; set last element
 tmp_pos[size(result_pos,/n_elements)]=current_pos.cur_ptr; set last
element

 result_header=tmp
 result_pos=tmp_pos ; set tmp vars to current result
endif

endif

endwhile
free_lun,unit
result={header:result_header, position:result_pos}
return,result
end

Thanks, Frank