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

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

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
RevLine 
[2]1;+
2;
[223]3; @file_comments
[133]4; Display an IDL procedure header using widgets and the widget manager.
[2]5;
[157]6; @categories
7; Widget
[2]8;
[223]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
[136]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.
[2]15;
[223]16; @keyword _EXTRA
[231]17; Used to pass keywords
[2]18;
[223]19; @restrictions
[136]20; Triggers the XMANAGER if it is not already in use.
[2]21;
[223]22; @examples
23; IDL> xhelp,'plt'
[2]24;
[223]25; @history
26; Written By Steve Richards, December 1990
[2]27;       Graceful error recovery, DMS, Feb, 1992.
28;       Modified to extract .pro documentation headers, PJR/ESRG mar94
[133]29;       Paul Ricchiazzi                            jun93
30;       Institute for Computational Earth System Science
31;       University of California, Santa Barbara
[2]32;  7/1/99 : legeres mofification par Sebastien Masson : utilisation de
33;  xdisplayfile, de findfile et de _extra.
[136]34;  6/7/1999: compatibility mac and windows
[133]35;
[223]36; @version
37; $Id$
[133]38;
[2]39;-
[231]40;
[2]41PRO xhelp, filename, _extra=ex
[114]42;
43  compile_opt idl2, strictarrsubs
44;
[2]45
[133]46; Are we sure filename is a string?
[2]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
[223]52; We have to find the full name
[2]53   pfile=FILENAME
[223]54   if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro"
[2]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
[136]68; We test each possible name to find where the file is.
[2]69   nfile=n_elements(pfile)
70   n = 0
71   repeat begin
[223]72      res = findfile(pfile[n])
[2]73      n = n+1
[223]74   endrep until res[0] NE '' OR n EQ n_elements(pfile)
[2]75   if res[0] NE '' then BEGIN
[133]76      openr, unit,pfile[n-1], /get_lun ; opening of the file
[223]77; we select the heading piece
[2]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
[141]86         if readon then BEGIN
87            dum=where(byte(c) eq 9b,ntab) ; count tab characters
88            xsize=xsize > (strlen(c)+8*ntab)
[114]89            a[i] = strmid(c,1,200)
[2]90            i = i + 1
91         endif
92         if strpos(c,';+') eq 0 then readon=1
93      endwhile
94      if i EQ 0 then $
[224]95         ras = report('file is badly written, no header ... Use xfile') ELSE BEGIN
[114]96         a = a[0:i-1]
[133]97; we wrote the a's content in a widget
[2]98         xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex
[223]99      ENDELSE
[2]100      FREE_LUN, unit         ;free the file unit.
[230]101   ENDIF ELSE ras = report(filename + ' does not exist ...')
[2]102
103   return
104end
105
Note: See TracBrowser for help on using the repository browser.