source: trunk/SRC/Utilities/xhelp.pro @ 157

Last change on this file since 157 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
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 your keywords
18;
19; @restrictions
20; Triggers the XMANAGER if it is not already in use.
21;
22; @examples
23; Open a file and create a widget to display its contents.
24;
25; @history Written By Steve Richards, December 1990
26;       Graceful error recovery, DMS, Feb, 1992.
27;       Modified to extract .pro documentation headers, PJR/ESRG mar94
28;       Paul Ricchiazzi                            jun93
29;       Institute for Computational Earth System Science
30;       University of California, Santa Barbara
31;  7/1/99 : legeres mofification par Sebastien Masson : utilisation de
32;  xdisplayfile, de findfile et de _extra.
33;  6/7/1999: compatibility mac and windows
34;
35; @version $Id$
36;
37;-
38PRO xhelp, filename, _extra=ex
39;
40  compile_opt idl2, strictarrsubs
41;
42
43; Are we sure filename is a string?
44   cquoidonc = size(filename, /type)
45   if cquoidonc NE 7 then begin
46      ras = report('Input parameter must be a string and not a '+size(filename, /tname))
47      return
48   endif
49; We have to find the full name
50   pfile=FILENAME
51   if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro"
52   thisOS = strupcase(strmid(!version.os_family, 0, 3))
53   CASE thisOS of
54      'MAC':BEGIN & sep = ':' & pathsep = ',' & end
55      'WIN':BEGIN & sep = '\' & pathsep = ';' & end
56      ELSE: BEGIN & sep = '/' & pathsep = ':' & end
57   ENDCASE
58   cd, current = current
59   if strpos(pfile,sep) lt 0 then BEGIN
60      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
61      multipath = str_sep(!path,pathsep)
62      if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep
63      pfile = [current, multipath]+ pfile
64   ENDIF
65; We test each possible name to find where the file is.
66   nfile=n_elements(pfile)
67   n = 0
68   repeat begin
69      res = findfile(pfile[n])
70      n = n+1
71   endrep until res[0] NE '' OR n EQ n_elements(pfile)
72   if res[0] NE '' then BEGIN
73      openr, unit,pfile[n-1], /get_lun ; opening of the file
74; we select the heading piece     
75      a = strarr(1000)          ;Maximum # of lines
76      xsize=0
77      i = 0
78      c = ''
79      readon=0
80      while not eof(unit) do begin
81         readf,unit,c
82         if strpos(c,';-') eq 0 then readon=0
83         if readon then BEGIN
84            dum=where(byte(c) eq 9b,ntab) ; count tab characters
85            xsize=xsize > (strlen(c)+8*ntab)
86            a[i] = strmid(c,1,200)
87            i = i + 1
88         endif
89         if strpos(c,';+') eq 0 then readon=1
90      endwhile
91      if i EQ 0 then $
92         ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN
93         a = a[0:i-1]
94; we wrote the a's content in a widget
95         xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex
96      ENDELSE
97      FREE_LUN, unit         ;free the file unit.
98   ENDIF ELSE ras = report('le fichier demande n''existe pas...')
99
100   return
101end
102
Note: See TracBrowser for help on using the repository browser.