source: trunk/UTILITAIRE/xhelp.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1;+
2; NAME:
3;       xhelp
4;
5; PURPOSE:
6;       Display an IDL procedure header using widgets and the widget manager.
7;
8; CATEGORY:
9;       Widgets.
10;
11; CALLING SEQUENCE:
12;       xhelp, Filename,_extra=ex
13;
14; INPUTS:
15;     Filename: A scalar string that contains the filename of the file
16;               to display.  If FILENAME does not include a complete path
17;               specification, xhelp will search for the file in
18;               the current working directory and then each of the
19;               directories listed in !PATH environment variable.  The
20;               ".pro" file suffix will be appended if it is not supplied.
21;
22; KEYWORD PARAMETERS:
23;       Ceux de xdisplayfile
24;
25; OUTPUTS:
26;       No explicit outputs.  A file viewing widget is created.
27;
28; SIDE EFFECTS:
29;       Triggers the XMANAGER if it is not already in use.
30;
31; RESTRICTIONS:
32;       None.
33;
34; PROCEDURE:
35;       Open a file and create a widget to display its contents.
36;
37; MODIFICATION HISTORY:
38;       Written By Steve Richards, December 1990
39;       Graceful error recovery, DMS, Feb, 1992.
40;       Modified to extract .pro documentation headers, PJR/ESRG mar94
41;
42;  author:  Paul Ricchiazzi                            jun93
43;           Institute for Computational Earth System Science
44;           University of California, Santa Barbara
45;
46;  7/1/99 : legeres mofification par Sebastien Masson : utilisation de
47;  xdisplayfile, de findfile et de _extra.
48;  6/7/1999: compatibilite mac et windows
49;-
50PRO xhelp, filename, _extra=ex
51
52; filename est bien un string?
53   cquoidonc = size(filename, /type)
54   if cquoidonc NE 7 then begin
55      ras = report('Input parameter must be a string and not a '+size(filename, /tname))
56      return
57   endif
58; il faut trouver le nom complet
59   pfile=FILENAME
60   if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro"
61   thisOS = strupcase(strmid(!version.os_family, 0, 3))
62   CASE thisOS of
63      'MAC':BEGIN & sep = ':' & pathsep = ',' & end
64      'WIN':BEGIN & sep = '\' & pathsep = ';' & end
65      ELSE: BEGIN & sep = '/' & pathsep = ':' & end
66   ENDCASE
67   cd, current = current
68   if strpos(pfile,sep) lt 0 then BEGIN
69      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
70      multipath = str_sep(!path,pathsep)
71      if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep
72      pfile = [current, multipath]+ pfile
73   ENDIF
74; on test tous les noms possibles pour trouver ou est le fichier
75   nfile=n_elements(pfile)
76   n = 0
77   repeat begin
78      res = findfile(pfile[n])
79      n = n+1
80   endrep until res[0] NE '' OR n EQ n_elements(pfile)
81   if res[0] NE '' then BEGIN
82      openr, unit,pfile[n-1], /get_lun ; ouverture du fichier
83; on selectionne le morceaux en-tete     
84      a = strarr(1000)          ;Maximum # of lines
85      xsize=0
86      i = 0
87      c = ''
88      readon=0
89      while not eof(unit) do begin
90         readf,unit,c
91         if strpos(c,';-') eq 0 then readon=0
92         if readon then begin
93            dum=where(byte(c) eq 9b,ntab) ; count tab characters
94            xsize=xsize > (strlen(c)+8*ntab)
95            a(i) = strmid(c,1,200)
96            i = i + 1
97         endif
98         if strpos(c,';+') eq 0 then readon=1
99      endwhile
100      if i EQ 0 then $
101         ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN
102         a = a(0:i-1)
103; on ecrit le contenu de a ds un widget
104         xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex
105      ENDELSE
106      FREE_LUN, unit         ;free the file unit.
107   ENDIF ELSE ras = report('le fichier demande n''existe pas...')
108
109   return
110end
111
Note: See TracBrowser for help on using the repository browser.