function tip,file ;returns a string vector which contains the data from a tip-tilt log file. ;the ttdata array contains the time and raw tip data ;ttdata(0,*)=time (hms), ttdata(1,*)=I3 (Y), ttdata(2,*)=I2 (Z) ;if the file contains no data, the program returns ttdata='' close,1 openr,1,file ;find out how many lines are in the file... command='wc -l '+file spawn,command,length length=length(0) length=strmid(length,0,strpos(length,' ')) length=long(length) if length eq 0 then begin print,string(10b),string(7b),'This is a null file: ',file ttdata='' goto,exit endif ;setup to collect data for both sensors (I2,I3)... ttdata=strarr(3,length) ;ttdata contains the tip tilt data (see above) dataflag=intarr(2) ;tracks whether data exists for both sensors, y & z line='' ;line=string containg the data in the current line n=0 ;n tracks the number of data points while not eof(1) do begin readf,1,line,format='(a)' start=strmid(line,0,2) ;start=first 2 characters of the line if start eq '$G' then begin ;gps data line gps: ttdata(0,n)=strmid(line,7,6) ;store gps time again: readf,1,line ;read the next line if eof(1) eq 1 then goto,finish ;quit at end of file start=strmid(line,0,2) ;first 2 characters if dataflag(0) and dataflag(1) eq 1 then begin ;when y & z data taken n=n+1 ;increment n ttdata(0,n)=ttdata(0,n-1) ;set time eq. last gps time dataflag=[0,0] ;reset flags endif if start eq '$G' then goto,gps if start eq 'I2' then ttdata(2,n)=strmid(line,3,7) if start eq 'I2' then dataflag(1)=1 if start eq 'I3' then ttdata(1,n)=strmid(line,3,7) if start eq 'I3' then dataflag(0)=1 goto,again endif endwhile finish: ;was any data collected?... if n eq 0 then begin Print,'No GPS data in: ,file ttdata='' goto,exit endif ;trim-off unused portion of data array... temp=ttdata(*,0:n-1) ttdata=fltarr(3,n) ttdata=temp exit: return,ttdata close,1 end