function read_dat,inpath,maxrec=maxrec ;this function is in test to read the txt file ;---------------------------------------------------- if n_elements(maxrec) eq 0 then maxrec = 140000L stru = {wv:0.0,percent:0.0} ;a structure to hold one line of the data file record =replicate(stru,maxrec) ;hold all data ;filepath='H:\yiqun\class\605\SeminarExample.txt' openr,lun,inpath,/get_lun ;need a container to hold one line of text trash = 'garbage' ;let's skip the first four lines ;P ;readf,lun,trash ;readf,lun,trash ;readf,lun,trash ;readf,lun,trash ;fmt='(f6.0,f6.1)' i=0L while(not eof(lun)) do begin readf,lun,stru;,format=fmt ;put the line we ju st read into our arrays record(i) = stru i=i+1L ;Check to make sure maxrec isn't exceeded if i ge maxrec then message,'WARNING: MAXREC TOO SMALL! Please increase.' endwhile record=record[0:i-1L] free_lun,lun return,record end