[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[133] | 3 | ; @file_comments |
---|
| 4 | ; Display an IDL procedure header using widgets and the widget manager. |
---|
[2] | 5 | ; |
---|
[133] | 6 | ; @categories Widgets. |
---|
[2] | 7 | ; |
---|
[133] | 8 | ; @param Filename {in}{required} A scalar string that contains the filename of the file |
---|
[2] | 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 | ; |
---|
[133] | 15 | ; @keyword _extra used to pass your keywords |
---|
[2] | 16 | ; |
---|
[133] | 17 | ; @restrictions Triggers the XMANAGER if it is not already in use. |
---|
[2] | 18 | ; |
---|
[133] | 19 | ; @examples Open a file and create a widget to display its contents. |
---|
[2] | 20 | ; |
---|
[133] | 21 | ; @history Written By Steve Richards, December 1990 |
---|
[2] | 22 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
| 23 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
[133] | 24 | ; Paul Ricchiazzi jun93 |
---|
| 25 | ; Institute for Computational Earth System Science |
---|
| 26 | ; University of California, Santa Barbara |
---|
[2] | 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 |
---|
[133] | 30 | ; |
---|
| 31 | ; @version $Id$ |
---|
| 32 | ; |
---|
[2] | 33 | ;- |
---|
| 34 | PRO xhelp, filename, _extra=ex |
---|
[114] | 35 | ; |
---|
| 36 | compile_opt idl2, strictarrsubs |
---|
| 37 | ; |
---|
[2] | 38 | |
---|
[133] | 39 | ; Are we sure filename is a string? |
---|
[2] | 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 |
---|
[133] | 45 | ; We have to find the full name |
---|
[2] | 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 |
---|
[133] | 61 | ; We test each possile name to find where the file is. |
---|
[2] | 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 |
---|
[133] | 69 | openr, unit,pfile[n-1], /get_lun ; opening of the file |
---|
| 70 | ; we select the heading piece |
---|
[2] | 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 |
---|
[114] | 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) |
---|
[2] | 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 |
---|
[114] | 89 | a = a[0:i-1] |
---|
[133] | 90 | ; we wrote the a's content in a widget |
---|
[2] | 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 |
---|
| 97 | end |
---|
| 98 | |
---|