;+ ; NAME: ; nthline_lookup ; ; PURPOSE: (one line) ; make a lookup table for use by nthline ; ; DESCRIPTION: ; make a lookup table for use by nthline ; ; CATEGORY: ; File IO ; ; CALLING SEQUENCE: ; nthline_lookup, filename, lookup=lookup, recalc=recalc ; ; INPUTS: ; filename - file for which to make the lookup ; ; OPTIONAL INPUT PARAMETERS: ; ; KEYWORD INPUT PARAMETERS: ; ; lookup - name of lookup table (otherwise filename.lookup) ; recalc - if set, recalculate and save lookup table, even if file exists ; ; KEYWORD OUTPUT PARAMETERS: ; ; OUTPUTS: ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; Creates lookup table, a file of 2 x n longs ; startbyte nbyte ; ; PROCEDURES: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY: ; Written 2006 Apr 23 Leslie Young SwRI ;- pro nthline_lookup, filename, lookup=lookup, recalc=recalc if not keyword_set(lookup) then lookup=filename+'.lookup' tmp = ' ' if not isfile(filename) then begin print, 'Error: file ' + filename + ' does not exist' return end if not isfile(lookup) or keyword_set(recalc) then begin openr, ilun, filename, /get_lun openw, olun, lookup, /get_lun startbyte = 0L repeat begin readf,ilun,tmp reclen = strlen(tmp) writeu, olun, startbyte, reclen startbyte = startbyte + reclen + 1 ; add 1 for EOL endrep until eof(ilun) close, ilun & free_lun,ilun close, olun & free_lun,olun endif end