source: trunk/SRC/Utilities/xfile.pro @ 285

Last change on this file since 285 was 285, checked in by smasson, 17 years ago

allways return back a scalar is /firstfound used

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1;+
2;
3; @file_comments
4; display an ASCII file in a widget.
5; It is the same thing that <proidl>XDISPLAYFILE</proidl> but here, we use it
6; to display the content of a procedure or of a function located in the !path
7; ".pro" suffix will be appended if needed.
8;
9; @categories
10; Utilities Widget
11;
12; @param FILENAME {in}{required} {type=scalar string}
13; It is the name of the procedure or of the function
14; we want to display (with or without .pro at the end).
15; FILENAME should be located in !path.
16; ".pro" suffix will be appended if needed.
17;
18; @keyword _EXTRA
19; Used to pass keywords to <proidl>XDISPLAYFILE</proidl>
20;
21; @restrictions
22; Triggers the <proidl>XMANAGER</proidl> if it is not already in use.
23;
24; @examples
25; IDL> xfile,'plt'
26;
27; @history
28; Sebastien Masson (smasson\@lodyc.jussieu.fr)
29; 7/1/99
30; 6/7/1999: compatibility mac and windows
31;
32; @version
33; $Id$
34;
35;-
36;
37PRO xfile, filename, _EXTRA = ex
38;
39  compile_opt idl2, strictarrsubs
40;
41  usage="xfile, filename, _EXTRA = ex"
42;
43; check parameters
44  check_param = N_PARAMS()
45  if (check_param EQ 0) then begin
46     dummy = report(['No input parameter', $
47                     'Usage : ' + usage])
48     return
49  endif
50;
51; check arguments
52  if arg_present(filename) then begin
53     dummy = report(['No input parameter filename', $
54                     'Usage : ' + usage])
55     return
56  endif
57;
58; Are we sure filename is a string?
59   intype = size(filename, /type)
60   if intype NE 7 then begin
61      dummy = report(['Input parameter filename type : ' + size(filename,/TNAME) , $
62                      'Input parameter filename must be a string'])
63      return
64   endif
65;
66; find the file and display it!
67   pfile = find(filename, /firstfound)
68   if (pfile NE 'NOT FOUND') then begin
69     xdisplayfile, pfile[0], _EXTRA = ex
70   endif else begin
71     dummy = report(['Input parameter filename : ' + filename, $
72                     filename + ' does not exist ...'])
73   endelse
74;
75   return
76end
Note: See TracBrowser for help on using the repository browser.