Changeset 239 for trunk/SRC/Utilities
- Timestamp:
- 03/28/07 08:50:03 (17 years ago)
- Location:
- trunk/SRC/Utilities
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Utilities/createfunc.pro
r231 r239 72 72 ; update the list of .pro and .sav in !PATH 73 73 path_cache, /rebuild 74 ; do we really use shortfilename? 75 list = find(shortfilename, /onlypro, /firstfound) 76 IF list[0] NE filename THEN BEGIN ; it is ok if filename is the first one 77 dummy = report(['Several files ' + shortfilename + ' are found in the !path and' $ 78 , list[0] + ' we be used instead of', filename, 'We stop...'], /simple) 79 stop 80 ENDIF 74 81 ; compile it 75 82 resolve_routine, shortfilename, /is_function -
trunk/SRC/Utilities/createpro.pro
r232 r239 82 82 ; update the list of .pro and .sav in !PATH 83 83 path_cache, /rebuild 84 ; do we really use shortfilename? 85 list = find(shortfilename, /onlypro, /firstfound) 86 IF list[0] NE filename THEN BEGIN ; it is ok if filename is the first one 87 dummy = report(['Several files ' + shortfilename + ' are found in the !path and' $ 88 , list[0] + ' we be used instead of', filename, 'We stop...'], /simple) 89 stop 90 ENDIF 84 91 ; compile it 85 92 resolve_routine, shortfilename -
trunk/SRC/Utilities/def_myuniquetmpdir.pro
r231 r239 39 39 file_mkdir, myuniquetmpdir 40 40 ; add it to !path 41 !path = !path+ ':' + expand_path(myuniquetmpdir)41 !path = myuniquetmpdir + path_sep(/search_path) + !path 42 42 ENDIF 43 43 ; -
trunk/SRC/Utilities/find.pro
r238 r239 116 116 compile_opt idl2, strictarrsubs 117 117 ; 118 cd, current = current 119 current = (file_search(current, /test_directory, /mark_directory))[0] 118 120 CASE 1 OF 119 121 keyword_set(lookalldir):BEGIN 120 122 @cm_general 121 dirnames = [ './', iodir, homedir, !path]123 dirnames = [current, iodir, homedir, !path] 122 124 tstdtadir= file_dirname(find('find', /onlypro), /mark_directory) 123 tstdtadir = (file_search(tstdtadir+'../../DATA/TestsData'))[0] 125 parent = path_sep(/parent_directory)+path_sep() 126 tstdtadir = (file_search(tstdtadir+parent+parent+'DATA/TestsData'))[0] 124 127 IF tstdtadir NE '' THEN dirnames = [tstdtadir, dirnames] 125 128 END 126 129 keyword_set(iodirectory): dirnames = iodirectory 127 130 keyword_set(repertoire): dirnames = repertoire 128 ELSE: dirnames = [ './', !path]131 ELSE: dirnames = [current, !path] 129 132 ENDCASE 130 133 tmp = dirnames -
trunk/SRC/Utilities/mergeonline_help.pro
r231 r239 154 154 homehtml = strsed(homehtml, 'src=\"', 'src="'+homeidl) 155 155 ; except for SAXOIDL_OnlineHelp_title.png 156 homehtml = strsed(homehtml, 'src=\".*IDL_OnlineHelp_Title\.gif\"', 'src="' + homesaxo + '../xmldoc/images/SAXOIDL_OnlineHelp_title.png"') 156 parent = path_sep(/parent_directory)+path_sep() 157 homehtml = strsed(homehtml, 'src=\".*IDL_OnlineHelp_Title\.gif\"', 'src="' + homesaxo + parent + 'xmldoc/images/SAXOIDL_OnlineHelp_title.png"') 157 158 ; 158 159 putfile, homesrc + 'home.html', temporary(homehtml) … … 160 161 ; build homesrc + 'aboutsaxo.txt' 161 162 ;--------------------------------------------------------------- 162 about = getfile(homesaxo + '../../overview')163 about = getfile(homesaxo + parent + parent + 'overview') 163 164 ; remove the lines containing @ 164 165 lines = strmatch(about, '@*') -
trunk/SRC/Utilities/report.pro
r232 r239 69 69 res = -1 ; 70 70 ; we separate the text in different lines (separated by !C) if it is not already done... 71 71 if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim) 72 72 ; there is some widgets activated, it is easy, we call dialog_massage 73 74 75 76 77 73 if (widget_info(/managed))[0] NE 0 then BEGIN 74 res = dialog_message(text, dialog_parent = parent, QUESTION = question $ 75 , title = routine_name(1), DEFAULT_NO = default_no, _extra = ex) 76 if keyword_set(question) THEN res = res EQ 'Yes' ELSE res = -1 77 ENDIF ELSE BEGIN 78 78 ; there is not any widget activated 79 79 ; do we ask a question ? 80 80 if keyword_set(question) then BEGIN 81 81 ; what i sthe answer by default ? 82 83 84 85 for i = 0, n_elements(text)-2 do print,text[i]86 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer87 82 if keyword_set(default_no) then answer = 'n' ELSE answer = 'y' 83 default_answer = answer 84 if n_elements(text) GT 1 THEN $ 85 for i = 0, n_elements(text)-2 do print, text[i] 86 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 87 answer = strlowcase(answer) ; 88 88 ; if the answer is not appropriated 89 90 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer91 92 ENDWHILE;89 while answer NE '' and answer NE 'y' and answer NE 'n' do begin 90 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 91 answer = strlowcase(answer) 92 ENDWHILE ; 93 93 ; we adjust res in function of th answer 94 case answer of 95 '':res = default_answer EQ 'y' 96 'y':res = 1 97 'n':res = 0 98 endcase 99 endif ELSE BEGIN 94 case answer of 95 '':res = default_answer EQ 'y' 96 'y':res = 1 97 'n':res = 0 98 endcase 99 ENDIF 100 ENDELSE 100 101 ; If we do not ask any question, we just make a print 101 IF keyword_set(simple) THEN prefix = '' ELSE prefix = '% '+routine_name(1)+': '102 if n_elements(text) GT 1 THEN $103 for i = 0, n_elements(text)-2 do print, prefix+text[i]104 print, prefix+text[n_elements(text)-1]105 ENDELSE106 ENDELSE102 IF NOT keyword_set(question) THEN BEGIN 103 IF keyword_set(simple) THEN prefix = '' ELSE prefix = '% '+routine_name(1)+': ' 104 if n_elements(text) GT 1 THEN $ 105 for i = 0, n_elements(text)-2 do print, prefix+text[i] 106 print, prefix+text[n_elements(text)-1] 107 ENDIF 107 108 108 109 return, res -
trunk/SRC/Utilities/xfile.pro
r232 r239 3 3 ; @file_comments 4 4 ; display in a widget an ASCII file. 5 ; It is the same thing that xdisplayfilebut here, we use it6 ; to display the content of a procedure or of a function ,7 ; even if it is not in the current directory (thanks to the path).5 ; It is the same thing that <proidl>xdisplayfile<proidl> but here, we use it 6 ; to display the content of a procedure or of a function located in the !path 7 ; ".pro" suffix will be appended if needed. 8 8 ; 9 9 ; @categories … … 15 15 ; 16 16 ; @keyword _EXTRA 17 ; Used to pass keywords 17 ; Used to pass keywords to <proidl>xdisplayfile</proidl> 18 18 ; 19 19 ; @examples … … 34 34 compile_opt idl2, strictarrsubs 35 35 ; 36 pfile = strlowcase(filename) 37 ; 38 ; we have to find the full name. 39 ; 40 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 41 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 42 CASE thisOS of 43 'MAC':BEGIN & sep = ':' & pathsep = ',' & end 44 'WIN':BEGIN & sep = '\' & pathsep = ';' & end 45 ELSE: BEGIN & sep = '/' & pathsep = ':' & end 46 ENDCASE 47 cd, current = current 48 if strpos(pfile,sep) lt 0 then BEGIN 49 if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep 50 multipath = str_sep(!path,pathsep) 51 if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep 52 pfile = [current, multipath]+ pfile 53 ENDIF 54 i = 0 55 repeat begin 56 res = findfile(pfile[i]) 57 i = i+1 58 endrep until res[0] NE '' OR i EQ n_elements(pfile) 59 if res[0] NE '' then BEGIN 60 ; we open the file in a widget 61 xdisplayfile, pfile[i-1], _extra = ex 62 ENDIF ELSE ras = report(filename + ' does not exist ...') 63 ; 64 ; 36 ; Are we sure filename is a string? 37 intype = size(filename, /type) 38 if intype NE 7 then begin 39 dummy = report('Input parameter must be a string and not a '+size(filename, /tname)) 40 return 41 endif 42 ; find the file and display it! 43 pfile = find(filename, /first_found) 44 IF pfile NE 'NOT_FOUND' THEN xdisplayfile, pfile[0], _extra = ex $ 45 ELSE dummy = report(filename + ' does not exist ...') 46 65 47 return 66 48 end -
trunk/SRC/Utilities/xhelp.pro
r232 r239 9 9 ; @param FILENAME {in}{required} 10 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. 11 ; Filename should be located in !path. 12 ; ".pro" suffix will be appended if needed. 15 13 ; 16 14 ; @keyword _EXTRA 17 ; Used to pass keywords 15 ; Used to pass keywords to <proidl>xdisplayfile</proidl> 18 16 ; 19 17 ; @restrictions … … 45 43 46 44 ; Are we sure filename is a string? 47 cquoidonc= size(filename, /type)48 if cquoidoncNE 7 then begin49 ras= report('Input parameter must be a string and not a '+size(filename, /tname))45 intype = size(filename, /type) 46 if intype NE 7 then begin 47 dummy = report('Input parameter must be a string and not a '+size(filename, /tname)) 50 48 return 51 49 endif 52 ; We have to find the full name 53 pfile=FILENAME 54 if strpos(pfile,".pro") lt 0 then pfile=pfile+".pro" 55 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 56 CASE thisOS of 57 'MAC':BEGIN & sep = ':' & pathsep = ',' & end 58 'WIN':BEGIN & sep = '\' & pathsep = ';' & end 59 ELSE: BEGIN & sep = '/' & pathsep = ':' & end 60 ENDCASE 61 cd, current = current 62 if strpos(pfile,sep) lt 0 then BEGIN 63 if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep 64 multipath = str_sep(!path,pathsep) 65 if rstrpos(multipath[0],sep) NE strlen(multipath[0])-1 then multipath = multipath +sep 66 pfile = [current, multipath]+ pfile 67 ENDIF 68 ; We test each possible name to find where the file is. 69 nfile=n_elements(pfile) 70 n = 0 71 repeat begin 72 res = findfile(pfile[n]) 73 n = n+1 74 endrep until res[0] NE '' OR n EQ n_elements(pfile) 75 if res[0] NE '' then BEGIN 76 openr, unit,pfile[n-1], /get_lun ; opening of the file 77 ; we select the heading piece 78 a = strarr(1000) ;Maximum # of lines 79 xsize=0 80 i = 0 81 c = '' 82 readon=0 83 while not eof(unit) do begin 84 readf,unit,c 85 if strpos(c,';-') eq 0 then readon=0 86 if readon then BEGIN 87 dum=where(byte(c) eq 9b,ntab) ; count tab characters 88 xsize=xsize > (strlen(c)+8*ntab) 89 a[i] = strmid(c,1,200) 90 i = i + 1 91 endif 92 if strpos(c,';+') eq 0 then readon=1 93 endwhile 94 if i EQ 0 then $ 95 ras = report('file is badly written, no header ... Use xfile') ELSE BEGIN 96 a = a[0:i-1] 97 ; we wrote the a's content in a widget 98 xdisplayfile,'toto',text = a,title=pfile[n-1], _extra = ex 99 ENDELSE 100 FREE_LUN, unit ;free the file unit. 101 ENDIF ELSE ras = report(filename + ' does not exist ...') 50 ; find the file and display it! 51 pfile = (find(filename, /first_found))[0] 52 ; read it 53 IF pfile NE 'NOT_FOUND' THEN BEGIN 54 fulltext = getfile(pfile) 55 ; find the ";+"and ";-" 56 start = where(stregex(fulltext,'^ *;\+ *$', /boolean) EQ 1, cnt1) 57 ending = where(stregex(fulltext,'^ *;- *$', /boolean) EQ 1, cnt2) 58 IF cnt1 EQ 0 OR cnt1 NE cnt2 THEN BEGIN 59 dummy = report('file '+pfile+' is badly written, no proper header found... Use xfile') 60 return 61 ENDIF 62 ; do we have hidden parts? 63 hide = where(stregex(fulltext, '^ *; *@hidden *$', /boolean) EQ 1) 64 ; buid the text to display 65 header = '' 66 sepbloc = ['', string(replicate(byte('='), 60)), ''] 67 FOR i = 0, cnt1-1 DO BEGIN 68 ; is this part hidden ? 69 st = start[i] 70 ed = ending[i] 71 IF st NE ed +1 THEN BEGIN ; non-empty bloc 72 dummy = where(hide GT st AND hide LT ed, cnt) 73 IF cnt EQ 0 THEN header = [header, '', sepbloc, fulltext[st+1:ed-1]] 74 ENDIF 75 ENDFOR 76 ; remove the fisrt useless lines 77 IF n_elements(header) GT 1 THEN header = header[4:*] ELSE BEGIN 78 dummy = report('file '+pfile+' has empty header... Use xfile') 79 return 80 ENDELSE 81 ; 82 xdisplayfile, 'dummy', text = header[1:*], title = pfile, _extra = ex 83 ; 84 ENDIF ELSE dummy = report(filename + ' does not exist ...') 102 85 103 86 return
Note: See TracChangeset
for help on using the changeset viewer.