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

Last change on this file since 310 was 262, checked in by pinsard, 17 years ago

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1;+
2;
3; @file_comments
4; Write a text file from a string array.
5;
6; @categories
7;
8; @param FILE {in}{required}{type=string}
9; = text file name.
10;
11; @param S {in}{required}{type=string or array}
12; = string array.
13;
14; @keyword ERROR
15; =err  error flag: 0=ok, 1=invalid string array.
16;
17; @history
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.
26;
27; @version
28; $Id$
29;
30;-
31;
32PRO putfile, file, s, ERROR=err, HELP=hlp
33;
34  compile_opt idl2, strictarrsubs
35;
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
62          t = s[i]
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
Note: See TracBrowser for help on using the repository browser.