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