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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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