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

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

improvements of some *.pro

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; display in a widget an ASCII file.
8; It is the same thing that xdisplayfile but here, we use it
9; to display the content of a procedure or of a function,
10; even if it is not in the current directory (thanks to the path).
11;
12; @categories
13; Utilities
14;
15; @param FILENAME {in}{required}
16; It is the name of the procedure or of the function
17; we want to display (with or without .pro at the end).
18;
19; @keyword _EXTRA
20; used to pass your keywords
21;
22; @examples
23; IDL> xfile,'plt'
24;
25; @history
26; Sebastien Masson (smasson\@lodyc.jussieu.fr)
27; 7/1/99
28; 6/7/1999: compatibility mac and windows
29;
30; @version
31; $Id$
32;
33;-
34;------------------------------------------------------------
35;------------------------------------------------------------
36;------------------------------------------------------------
37PRO xfile, filename, _extra = ex
38;
39  compile_opt idl2, strictarrsubs
40;
41pfile = strlowcase(filename)
42;
43; we have to find the full name.
44;
45   if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro"
46   thisOS = strupcase(strmid(!version.os_family, 0, 3))
47   CASE thisOS of
48      'MAC':BEGIN & sep = ':' & pathsep = ',' & end
49      'WIN':BEGIN & sep = '\' & pathsep = ';' & end
50      ELSE: BEGIN & sep = '/' & pathsep = ':' & end
51   ENDCASE
52   cd, current = current
53   if strpos(pfile,sep) lt 0 then BEGIN
54      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
55      multipath = str_sep(!path,pathsep)
56      if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep
57      pfile = [current, multipath]+ pfile
58   ENDIF
59   i = 0
60   repeat begin
61      res = findfile(pfile[i])
62      i = i+1
63   endrep until res[0] NE '' OR i EQ n_elements(pfile)
64   if res[0] NE  '' then BEGIN
65; we open the file in a widget
66   xdisplayfile, pfile[i-1], _extra = ex
67   ENDIF ELSE ras = report('file does not exist ...')
68;
69;
70   return
71end
Note: See TracBrowser for help on using the repository browser.