source: trunk/SRC/ToBeReviewed/UTILITAIRE/xhelp.pro @ 114

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • 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  compile_opt idl2, strictarrsubs
53;
54
55; filename est bien un string?
56   cquoidonc = size(filename, /type)
57   if cquoidonc NE 7 then begin
58      ras = report('Input parameter must be a string and not a '+size(filename, /tname))
59      return
60   endif
61; il faut trouver le nom complet
62   pfile=FILENAME
63   if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro"
64   thisOS = strupcase(strmid(!version.os_family, 0, 3))
65   CASE thisOS of
66      'MAC':BEGIN & sep = ':' & pathsep = ',' & end
67      'WIN':BEGIN & sep = '\' & pathsep = ';' & end
68      ELSE: BEGIN & sep = '/' & pathsep = ':' & end
69   ENDCASE
70   cd, current = current
71   if strpos(pfile,sep) lt 0 then BEGIN
72      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
73      multipath = str_sep(!path,pathsep)
74      if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep
75      pfile = [current, multipath]+ pfile
76   ENDIF
77; on test tous les noms possibles pour trouver ou est le fichier
78   nfile=n_elements(pfile)
79   n = 0
80   repeat begin
81      res = findfile(pfile[n])
82      n = n+1
83   endrep until res[0] NE '' OR n EQ n_elements(pfile)
84   if res[0] NE '' then BEGIN
85      openr, unit,pfile[n-1], /get_lun ; ouverture du fichier
86; on selectionne le morceaux en-tete     
87      a = strarr(1000)          ;Maximum # of lines
88      xsize=0
89      i = 0
90      c = ''
91      readon=0
92      while not eof(unit) do begin
93         readf,unit,c
94         if strpos(c,';-') eq 0 then readon=0
95         if readon then begin
96            dum=where(byte[c] eq 9b,ntab) ; count tab characters
97            xsize=xsize > (strlen[c]+8*ntab)
98            a[i] = strmid(c,1,200)
99            i = i + 1
100         endif
101         if strpos(c,';+') eq 0 then readon=1
102      endwhile
103      if i EQ 0 then $
104         ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN
105         a = a[0:i-1]
106; on ecrit le contenu de a ds un widget
107         xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex
108      ENDELSE
109      FREE_LUN, unit         ;free the file unit.
110   ENDIF ELSE ras = report('le fichier demande n''existe pas...')
111
112   return
113end
114
Note: See TracBrowser for help on using the repository browser.