;  FILE_STRARR.PRO    5-27-94
;
; Routine to read text file and return a STRARR containing
; the lines of text. Returns a STRARR(2) containing the null 
; string '' and the value of !err_string if an I/O error is encountered
;
; This code adapted from XDISPLAYFILE

FUNCTION file_strarr, fname

ON_IOERROR, IO_ERROR

openr, unit, fname, /get_lun, error=err
if (err ne 0) then begin
	return, ['ERROR', !err_string]
endif else begin
	max_lines = 1000
	a = strarr(max_lines)
	i = 0
	c = ''
	while (not eof(unit)) do begin
		readf, unit, c
		a[i] = c
		i = i + 1
		if (i eq max_lines - 2) then begin
			a = [a, strarr(max_lines)]
			max_lines = max_lines + max_lines
		endif
	endwhile
	a = a[0:i-1]
	free_lun, unit
	return, a
endelse

IO_ERROR:
	message, 'Error reading file: ' + fname, /continue
	print, !err_string
	return, ['ERROR', !err_string]

END


