source: trunk/SRC/ToBeReviewed/STRING/putfile.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

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