;+ ; NAME: ; xhelp ; ; PURPOSE: ; Display an IDL procedure header using widgets and the widget manager. ; ; CATEGORY: ; Widgets. ; ; CALLING SEQUENCE: ; xhelp, Filename,_extra=ex ; ; INPUTS: ; Filename: A scalar string that contains the filename of the file ; to display. If FILENAME does not include a complete path ; specification, xhelp will search for the file in ; the current working directory and then each of the ; directories listed in !PATH environment variable. The ; ".pro" file suffix will be appended if it is not supplied. ; ; KEYWORD PARAMETERS: ; Ceux de xdisplayfile ; ; OUTPUTS: ; No explicit outputs. A file viewing widget is created. ; ; SIDE EFFECTS: ; Triggers the XMANAGER if it is not already in use. ; ; RESTRICTIONS: ; None. ; ; PROCEDURE: ; Open a file and create a widget to display its contents. ; ; MODIFICATION HISTORY: ; Written By Steve Richards, December 1990 ; Graceful error recovery, DMS, Feb, 1992. ; Modified to extract .pro documentation headers, PJR/ESRG mar94 ; ; author: Paul Ricchiazzi jun93 ; Institute for Computational Earth System Science ; University of California, Santa Barbara ; ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de ; xdisplayfile, de findfile et de _extra. ; 6/7/1999: compatibilite mac et windows ;- PRO xhelp, filename, _extra=ex ; filename est bien un string? cquoidonc = size(filename, /type) if cquoidonc NE 7 then begin ras = report('Input parameter must be a string and not a '+size(filename, /tname)) return endif ; il faut trouver le nom complet pfile=FILENAME if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" thisOS = strupcase(strmid(!version.os_family, 0, 3)) CASE thisOS of 'MAC':BEGIN & sep = ':' & pathsep = ',' & end 'WIN':BEGIN & sep = '\' & pathsep = ';' & end ELSE: BEGIN & sep = '/' & pathsep = ':' & end ENDCASE cd, current = current if strpos(pfile,sep) lt 0 then BEGIN if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep multipath = str_sep(!path,pathsep) if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep pfile = [current, multipath]+ pfile ENDIF ; on test tous les noms possibles pour trouver ou est le fichier nfile=n_elements(pfile) n = 0 repeat begin res = findfile(pfile[n]) n = n+1 endrep until res[0] NE '' OR n EQ n_elements(pfile) if res[0] NE '' then BEGIN openr, unit,pfile[n-1], /get_lun ; ouverture du fichier ; on selectionne le morceaux en-tete a = strarr(1000) ;Maximum # of lines xsize=0 i = 0 c = '' readon=0 while not eof(unit) do begin readf,unit,c if strpos(c,';-') eq 0 then readon=0 if readon then begin dum=where(byte(c) eq 9b,ntab) ; count tab characters xsize=xsize > (strlen(c)+8*ntab) a(i) = strmid(c,1,200) i = i + 1 endif if strpos(c,';+') eq 0 then readon=1 endwhile if i EQ 0 then $ ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN a = a(0:i-1) ; on ecrit le contenu de a ds un widget xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex ENDELSE FREE_LUN, unit ;free the file unit. ENDIF ELSE ras = report('le fichier demande n''existe pas...') return end