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

Last change on this file since 327 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • 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;-
31PRO putfile, file, s, ERROR=err, HELP=hlp
32;
33  compile_opt idl2, strictarrsubs
34;
35 
36        if (n_params(0) lt 1) or keyword_set(hlp) then begin
37          print,' Write a text file from a string array.'
38          print,' putfile, f, s'
39          print,'   f = text file name.      in'
40          print,'   s = string array.        in'
41          print,' Keywords:'
42          print,'   ERROR=err  error flag: 0=ok, 1=invalid string array.'
43          return
44        endif
45;
46        if lmgr(/demo) then begin
47           print, 'you are in Demo mode. It is impossible to write a file'
48           return
49        endif
50;
51        if size(s, /type) ne 7 then begin
52          print,' Error in putfile: argument must be a string array.'
53          err = 1
54          return
55        endif
56 
57        get_lun, lun
58        openw, lun, file
59 
60        for i = 0, n_elements(s)-1 do begin
61          t = s[i]
62          if t eq '' then t = ' '
63          printf, lun, t
64        endfor
65 
66        close, lun
67        free_lun, lun
68        err = 0
69        return
70 
71        end
Note: See TracBrowser for help on using the repository browser.