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