[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[133] | 3 | ; @file_comments |
---|
| 4 | ; Display an IDL procedure header using widgets and the widget manager. |
---|
[2] | 5 | ; |
---|
[157] | 6 | ; @categories |
---|
| 7 | ; Widget |
---|
[2] | 8 | ; |
---|
[136] | 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 |
---|
| 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 | ; |
---|
[136] | 16 | ; @keyword _extra |
---|
| 17 | ; used to pass your keywords |
---|
[2] | 18 | ; |
---|
[136] | 19 | ; @restrictions |
---|
| 20 | ; Triggers the XMANAGER if it is not already in use. |
---|
[2] | 21 | ; |
---|
[136] | 22 | ; @examples |
---|
| 23 | ; Open a file and create a widget to display its contents. |
---|
[2] | 24 | ; |
---|
[133] | 25 | ; @history Written By Steve Richards, December 1990 |
---|
[2] | 26 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
| 27 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
[133] | 28 | ; Paul Ricchiazzi jun93 |
---|
| 29 | ; Institute for Computational Earth System Science |
---|
| 30 | ; University of California, Santa Barbara |
---|
[2] | 31 | ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de |
---|
| 32 | ; xdisplayfile, de findfile et de _extra. |
---|
[136] | 33 | ; 6/7/1999: compatibility mac and windows |
---|
[133] | 34 | ; |
---|
| 35 | ; @version $Id$ |
---|
| 36 | ; |
---|
[2] | 37 | ;- |
---|
| 38 | PRO xhelp, filename, _extra=ex |
---|
[114] | 39 | ; |
---|
| 40 | compile_opt idl2, strictarrsubs |
---|
| 41 | ; |
---|
[2] | 42 | |
---|
[133] | 43 | ; Are we sure filename is a string? |
---|
[2] | 44 | cquoidonc = size(filename, /type) |
---|
| 45 | if cquoidonc NE 7 then begin |
---|
| 46 | ras = report('Input parameter must be a string and not a '+size(filename, /tname)) |
---|
| 47 | return |
---|
| 48 | endif |
---|
[133] | 49 | ; We have to find the full name |
---|
[2] | 50 | pfile=FILENAME |
---|
| 51 | if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" |
---|
| 52 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
| 53 | CASE thisOS of |
---|
| 54 | 'MAC':BEGIN & sep = ':' & pathsep = ',' & end |
---|
| 55 | 'WIN':BEGIN & sep = '\' & pathsep = ';' & end |
---|
| 56 | ELSE: BEGIN & sep = '/' & pathsep = ':' & end |
---|
| 57 | ENDCASE |
---|
| 58 | cd, current = current |
---|
| 59 | if strpos(pfile,sep) lt 0 then BEGIN |
---|
| 60 | if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep |
---|
| 61 | multipath = str_sep(!path,pathsep) |
---|
| 62 | if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep |
---|
| 63 | pfile = [current, multipath]+ pfile |
---|
| 64 | ENDIF |
---|
[136] | 65 | ; We test each possible name to find where the file is. |
---|
[2] | 66 | nfile=n_elements(pfile) |
---|
| 67 | n = 0 |
---|
| 68 | repeat begin |
---|
| 69 | res = findfile(pfile[n]) |
---|
| 70 | n = n+1 |
---|
| 71 | endrep until res[0] NE '' OR n EQ n_elements(pfile) |
---|
| 72 | if res[0] NE '' then BEGIN |
---|
[133] | 73 | openr, unit,pfile[n-1], /get_lun ; opening of the file |
---|
| 74 | ; we select the heading piece |
---|
[2] | 75 | a = strarr(1000) ;Maximum # of lines |
---|
| 76 | xsize=0 |
---|
| 77 | i = 0 |
---|
| 78 | c = '' |
---|
| 79 | readon=0 |
---|
| 80 | while not eof(unit) do begin |
---|
| 81 | readf,unit,c |
---|
| 82 | if strpos(c,';-') eq 0 then readon=0 |
---|
[141] | 83 | if readon then BEGIN |
---|
| 84 | dum=where(byte(c) eq 9b,ntab) ; count tab characters |
---|
| 85 | xsize=xsize > (strlen(c)+8*ntab) |
---|
[114] | 86 | a[i] = strmid(c,1,200) |
---|
[2] | 87 | i = i + 1 |
---|
| 88 | endif |
---|
| 89 | if strpos(c,';+') eq 0 then readon=1 |
---|
| 90 | endwhile |
---|
| 91 | if i EQ 0 then $ |
---|
| 92 | ras = report('le programme a etait mal ecrit, il n''y a pas d''en-tete... utiliser xfile.pro.') ELSE BEGIN |
---|
[114] | 93 | a = a[0:i-1] |
---|
[133] | 94 | ; we wrote the a's content in a widget |
---|
[2] | 95 | xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex |
---|
| 96 | ENDELSE |
---|
| 97 | FREE_LUN, unit ;free the file unit. |
---|
| 98 | ENDIF ELSE ras = report('le fichier demande n''existe pas...') |
---|
| 99 | |
---|
| 100 | return |
---|
| 101 | end |
---|
| 102 | |
---|