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