1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Display an IDL procedure header using widgets and the widget manager. |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Widget |
---|
8 | ; |
---|
9 | ; @param FILENAME {in}{required} |
---|
10 | ; A scalar string that contains the filename of the file to display. |
---|
11 | ; If FILENAME does not include a complete path specification, xhelp will |
---|
12 | ; search for the file in the current working directory and then each of the |
---|
13 | ; directories listed in !PATH environment variable. The |
---|
14 | ; ".pro" file suffix will be appended if it is not supplied. |
---|
15 | ; |
---|
16 | ; @keyword _EXTRA |
---|
17 | ; Used to pass keywords |
---|
18 | ; |
---|
19 | ; @restrictions |
---|
20 | ; Triggers the XMANAGER if it is not already in use. |
---|
21 | ; |
---|
22 | ; @examples |
---|
23 | ; IDL> xhelp,'plt' |
---|
24 | ; |
---|
25 | ; @history |
---|
26 | ; Written By Steve Richards, December 1990 |
---|
27 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
28 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
29 | ; Paul Ricchiazzi jun93 |
---|
30 | ; Institute for Computational Earth System Science |
---|
31 | ; University of California, Santa Barbara |
---|
32 | ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de |
---|
33 | ; xdisplayfile, de findfile et de _extra. |
---|
34 | ; 6/7/1999: compatibility mac and windows |
---|
35 | ; |
---|
36 | ; @version |
---|
37 | ; $Id$ |
---|
38 | ; |
---|
39 | ;- |
---|
40 | ; |
---|
41 | PRO xhelp, filename, _EXTRA=ex |
---|
42 | ; |
---|
43 | compile_opt idl2, strictarrsubs |
---|
44 | ; |
---|
45 | |
---|
46 | ; Are we sure filename is a string? |
---|
47 | cquoidonc = size(filename, /type) |
---|
48 | if cquoidonc NE 7 then begin |
---|
49 | ras = report('Input parameter must be a string and not a '+size(filename, /tname)) |
---|
50 | return |
---|
51 | endif |
---|
52 | ; We have to find the full name |
---|
53 | pfile=FILENAME |
---|
54 | if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" |
---|
55 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
56 | CASE thisOS of |
---|
57 | 'MAC':BEGIN & sep = ':' & pathsep = ',' & end |
---|
58 | 'WIN':BEGIN & sep = '\' & pathsep = ';' & end |
---|
59 | ELSE: BEGIN & sep = '/' & pathsep = ':' & end |
---|
60 | ENDCASE |
---|
61 | cd, current = current |
---|
62 | if strpos(pfile,sep) lt 0 then BEGIN |
---|
63 | if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep |
---|
64 | multipath = str_sep(!path,pathsep) |
---|
65 | if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep |
---|
66 | pfile = [current, multipath]+ pfile |
---|
67 | ENDIF |
---|
68 | ; We test each possible name to find where the file is. |
---|
69 | nfile=n_elements(pfile) |
---|
70 | n = 0 |
---|
71 | repeat begin |
---|
72 | res = findfile(pfile[n]) |
---|
73 | n = n+1 |
---|
74 | endrep until res[0] NE '' OR n EQ n_elements(pfile) |
---|
75 | if res[0] NE '' then BEGIN |
---|
76 | openr, unit,pfile[n-1], /get_lun ; opening of the file |
---|
77 | ; we select the heading piece |
---|
78 | a = strarr(1000) ;Maximum # of lines |
---|
79 | xsize=0 |
---|
80 | i = 0 |
---|
81 | c = '' |
---|
82 | readon=0 |
---|
83 | while not eof(unit) do begin |
---|
84 | readf,unit,c |
---|
85 | if strpos(c,';-') eq 0 then readon=0 |
---|
86 | if readon then BEGIN |
---|
87 | dum=where(byte(c) eq 9b,ntab) ; count tab characters |
---|
88 | xsize=xsize > (strlen(c)+8*ntab) |
---|
89 | a[i] = strmid(c,1,200) |
---|
90 | i = i + 1 |
---|
91 | endif |
---|
92 | if strpos(c,';+') eq 0 then readon=1 |
---|
93 | endwhile |
---|
94 | if i EQ 0 then $ |
---|
95 | ras = report('file is badly written, no header ... Use xfile') ELSE BEGIN |
---|
96 | a = a[0:i-1] |
---|
97 | ; we wrote the a's content in a widget |
---|
98 | xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex |
---|
99 | ENDELSE |
---|
100 | FREE_LUN, unit ;free the file unit. |
---|
101 | ENDIF ELSE ras = report(filename + ' does not exist ...') |
---|
102 | |
---|
103 | return |
---|
104 | end |
---|
105 | |
---|