-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreadfile.pro
More file actions
46 lines (41 loc) · 894 Bytes
/
readfile.pro
File metadata and controls
46 lines (41 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FUNCTION readfile,file,filter=filter
;+
; NAME
; READFILE
;
; PURPOSE
; Read a text file into a string array
;
; CALLING SEQUENCE:
; return = readfile([file,filter=filter])
;
; INPUTS
; file - name of file to read
;
; filter - string to be used to filter files when using pickfile widget to select file.
;
; PACKAGE LOCATION
; http://www.astro.umd.edu/~eshaya/PDS/pds4readxml.tar
;
; MODIFICATION HISTORY
; Written by Ed Shaya (UMd) [May 3, 2012]
;-
;--------------
ON_ERROR,1
IF ~KEYWORD_SET(file) THEN $
file = DIALOG_PICKFILE(filter=filter)
IF (file eq '') THEN BEGIN
MESSAGE,'readfile: No file selected'
ENDIF
OPENR, lun, file, /GET_LUN
; Read one line at a time, saving the result into array
array = ''
line = ''
WHILE NOT EOF(lun) DO BEGIN
READF, lun, line
array = [array, line]
ENDWHILE
; Close the file and free the file unit
FREE_LUN, lun
RETURN, array
END