1 | ;------------------------------------------------------------- |
---|
2 | ;+ |
---|
3 | ; |
---|
4 | ; @file_comments |
---|
5 | ; Write a text file from a string array. |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; |
---|
9 | ; INPUTS: |
---|
10 | ; @param FILE {in}{required} |
---|
11 | ; = text file name. |
---|
12 | ; |
---|
13 | ; @param S {in}{required} |
---|
14 | ; = string array. |
---|
15 | ; |
---|
16 | ; @keyword ERROR |
---|
17 | ; =err error flag: 0=ok, 1=invalid string array. |
---|
18 | ; |
---|
19 | ; @history |
---|
20 | ; R. Sterner, 20 Mar, 1990 |
---|
21 | ; R. Sterner, 4 Nov, 1992 --- allowed scalar strings. |
---|
22 | ; |
---|
23 | ; Copyright (C) 1990, Johns Hopkins University/Applied Physics Laboratory |
---|
24 | ; This software may be used, copied, or redistributed as long as it is not |
---|
25 | ; sold and this copyright notice is reproduced on each copy made. This |
---|
26 | ; routine is provided as is without any express or implied warranties |
---|
27 | ; whatsoever. Other limitations apply as described in the file disclaimer.txt. |
---|
28 | ; |
---|
29 | ; @version |
---|
30 | ; $Id$ |
---|
31 | ; |
---|
32 | ;- |
---|
33 | ;------------------------------------------------------------- |
---|
34 | |
---|
35 | pro putfile, file, s, error=err, help=hlp |
---|
36 | ; |
---|
37 | compile_opt idl2, strictarrsubs |
---|
38 | ; |
---|
39 | |
---|
40 | if (n_params(0) lt 1) or keyword_set(hlp) then begin |
---|
41 | print,' Write a text file from a string array.' |
---|
42 | print,' putfile, f, s' |
---|
43 | print,' f = text file name. in' |
---|
44 | print,' s = string array. in' |
---|
45 | print,' Keywords:' |
---|
46 | print,' ERROR=err error flag: 0=ok, 1=invalid string array.' |
---|
47 | return |
---|
48 | endif |
---|
49 | ; |
---|
50 | if lmgr(/demo) then begin |
---|
51 | print, 'you are in Demo mode. It is impossible to write a file' |
---|
52 | return |
---|
53 | endif |
---|
54 | ; |
---|
55 | if size(s, /type) ne 7 then begin |
---|
56 | print,' Error in putfile: argument must be a string array.' |
---|
57 | err = 1 |
---|
58 | return |
---|
59 | endif |
---|
60 | |
---|
61 | get_lun, lun |
---|
62 | openw, lun, file |
---|
63 | |
---|
64 | for i = 0, n_elements(s)-1 do begin |
---|
65 | t = s[i] |
---|
66 | if t eq '' then t = ' ' |
---|
67 | printf, lun, t |
---|
68 | endfor |
---|
69 | |
---|
70 | close, lun |
---|
71 | free_lun, lun |
---|
72 | err = 0 |
---|
73 | return |
---|
74 | |
---|
75 | end |
---|