Changeset 239


Ignore:
Timestamp:
03/28/07 08:50:03 (17 years ago)
Author:
smasson
Message:

cleaning + minor bugfix related to the path definition

Location:
trunk/SRC
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Colors/lct.pro

    r232 r239  
    4343; definition of the name of the file containing colors palettes. 
    4444  if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 
    45 ; What is the full address of nametbl? 
    46   thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    47   CASE thisOS of 
    48   'MAC':BEGIN & sep = ':' & pathsep = ',' & end 
    49   'WIN':BEGIN & sep = '\' & pathsep = ';' & end 
    50   ELSE: BEGIN & sep = '/' & pathsep = ':' & end 
    51   ENDCASE 
    52   cd, current = current 
    53   if strpos(nametbl, sep) lt 0 then BEGIN 
    54     if rstrpos(current, sep) NE strlen(current)-1 then current = current+sep 
    55     multipath = str_sep(!path, pathsep) 
    56     for i = 0, n_elements(multipath)-1 do $ 
    57        if rstrpos(multipath[i], sep) NE strlen(multipath[i])-1 then $ 
    58           multipath[i] = multipath[i] +sep 
    59     nametbl = [current, multipath]+ nametbl 
    60   ENDIF 
    61 ; we test all possible name in order to find where file is. 
    62   nfile = n_elements(nametbl) 
    63   n = 0 
    64   repeat begin 
    65     res = findfile(nametbl[n]) 
    66     n = n+1 
    67   endrep until res[0] NE '' OR n EQ n_elements(nametbl) 
    68   if res[0] NE '' then BEGIN 
    69     nametbl = nametbl[n-1] 
     45; look for nametbl file 
     46  nametbl = (find(nametbl, /firstfound, /nopro))[0] 
     47  if nametbl NE 'NOT FOUND' then BEGIN 
    7048    if n_elements(ex) NE 0 then $ 
    7149       if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 
  • trunk/SRC/Colors/newpalette.pro

    r238 r239  
    3535  compile_opt idl2, strictarrsubs 
    3636; 
     37@cm_general 
     38; 
     39  homedir = isadirectory(homedir,  title = 'select MyIDL directory') 
    3740; definition of the name of the file containing colors palettes. 
    3841  if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 
    39 ; What is the full adress of nametbl? 
    40   homedir = isadirectory(homedir,  title = 'select MyIDL directory') 
     42; look for nametbl file 
    4143  namesave = nametbl 
    42   nametbl = find(nametbl) 
    43   if nametbl[0] NE 'NOT FOUND' then begin 
    44     nametbl = nametbl[0] 
    45     nameshort = file_basename(nametbl) 
    46 ; is nametbl belongs to the same effective user ID (UID) as the IDL process? 
    47     IF !d.name EQ 'X' THEN BEGIN ; works only for unix tye machine 
    48       IF file_test(nametbl, /user) NE 1 THEN BEGIN 
    49         noanswer = report('The file '+nametbl+' is not yours... Do you want to copy '+nameshort+' in your MyIDL directory: '+homedir+' ?', /default_no, /question) 
    50         IF noanswer THEN return ELSE BEGIN 
    51           file_copy, nametbl, homedir  ; copy the file 
    52           nametbl = homedir + nametbl  ; update its name 
    53         ENDELSE 
    54       ENDIF 
    55     ENDIF 
    56 ; no file nametbl found 
    57     ENDIF ELSE BEGIN 
     44  nametbl = (find(nametbl, /firstfound, /nopro))[0] 
     45; no file nametbl found, do we create one? 
     46  if nametbl EQ 'NOT FOUND' then BEGIN 
    5847      nametbl = file_basename(namesave)        ; get back the original nametbl 
    59       noanswer = report('The file '+nametbl+' was not found !path directories... Do you want to create such a file in  your MyIDL directory: '+homedir+' ?', /default_no, /question) 
     48      noanswer = report(['The file '+nametbl+' was not found !path directories.' $ 
     49                         , 'Do you want to create such a file in your MyIDL directory: '+homedir+' ?'] $ 
     50                        , /default_no, /question) 
    6051      if NOT noanswer then return 
    6152      nameorg = filepath('colors1.tbl', subdir = ['resource', 'colors']) 
    62       file_copy, nameorg, homedir 
     53      nametbl = homedir + file_basename(nametbl) ; update its name 
     54      file_copy, nameorg, nametbl                ; copy the file 
     55      file_chmod, nametbl, /u_write              ; make sure we have write access 
     56  ENDIF 
     57; do we have write access? 
     58  IF file_test(nametbl, /write) EQ 0 THEN BEGIN  
     59    noanswer = report(['You have no write access on file '+nametbl $ 
     60                       , 'Do you want to copy '+nameshort+' in your MyIDL directory: '+homedir+' ?'] $ 
     61                      , /default_no, /question) 
     62    IF noanswer THEN return ELSE BEGIN 
     63      nametbl = homedir + file_basename(nametbl) ; update its name 
     64      file_copy, nametbl, homedir, /allow_same   ; copy the file 
     65      file_chmod, nametbl, /u_write              ; make sure we have write access 
    6366    ENDELSE 
    64 ; is nametbl writable? 
    65     IF file_test(nametbl, /write) NE 1 THEN file_chmod, nametbl, /u_write 
     67  ENDIF  
    6668; make sure that we will really use nametbl name even if _EXTRA keyword is used 
    6769    if n_elements(ex) NE 0 then $ 
  • trunk/SRC/Colors/xlct.pro

    r237 r239  
    501501;----------------------------------------------------------------------------- 
    502502   IF N_ELEMENTS(file) GT 0 THEN filename = file ELSE BEGIN 
    503       filename = find('palette.tbl') 
    504       filename = filename[0] 
     503      filename = (find('palette.tbl', /firstfound, /nopro))[0] 
    505504      if filename EQ 'NOT FOUND' then filename=filepath('colors1.tbl',subdir=['resource', 'colors']) 
    506505   ENDELSE 
  • trunk/SRC/Documentation/xmldoc/idlfiles/init_example.pro

    r134 r239  
    1616; 
    1717!path = expand_path('+' + '/Users/sebastie/IDL') $ 
    18       + ':' + expand_path('+' + '/Users/sebastie/SAXO_RD') $ 
    19       + ':' + expand_path('+' + !dir) 
     18      + path_sep(/search_path) + expand_path('+' + '/Users/sebastie/SAXO_RD') $ 
     19      + path_sep(/search_path) + expand_path('+' + !dir) 
    2020; 
    2121; compatibility with the old version 
  • trunk/SRC/Documentation/xmldoc/savesaxo.sh

    r235 r239  
    156156@cm_general 
    157157file_copy, oldcm, myuniquetmpdir + 'oldcm_used.pro', /overwrite 
     158!path = myuniquetmpdir + ':' + !path 
    158159IF !journal NE 0 THEN journal 
    159160journal, myuniquetmpdir + 'cm_demomode_used.pro' 
    160161journal 
     162path_cache, /rebuild 
    161163; 
    162164resolve_all, resolve_either='keep_compatibility', skip_routines = ['xxx2ps','trends', 'label_gmt'] 
  • trunk/SRC/ForOldVersion/keep_compatibility.pro

    r238 r239  
    5555; 
    5656  IF n_elements(myuniquetmpdir) NE 0 THEN BEGIN 
    57     !path = !path+ ':' + expand_path(myuniquetmpdir) 
     57    !path = myuniquetmpdir + path_sep(/search_path) + !path 
    5858    return 
    5959  ENDIF 
  • trunk/SRC/Utilities/createfunc.pro

    r231 r239  
    7272; update the list of .pro and .sav in !PATH 
    7373   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 
    7481; compile it 
    7582   resolve_routine, shortfilename, /is_function 
  • trunk/SRC/Utilities/createpro.pro

    r232 r239  
    8282; update the list of .pro and .sav in !PATH 
    8383   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 
    8491; compile it 
    8592   resolve_routine, shortfilename 
  • trunk/SRC/Utilities/def_myuniquetmpdir.pro

    r231 r239  
    3939    file_mkdir, myuniquetmpdir 
    4040; add it to !path 
    41     !path = !path+ ':' + expand_path(myuniquetmpdir) 
     41    !path = myuniquetmpdir + path_sep(/search_path) + !path 
    4242  ENDIF 
    4343; 
  • trunk/SRC/Utilities/find.pro

    r238 r239  
    116116  compile_opt idl2, strictarrsubs 
    117117; 
     118  cd, current = current 
     119  current = (file_search(current, /test_directory, /mark_directory))[0] 
    118120  CASE 1 OF 
    119121    keyword_set(lookalldir):BEGIN 
    120122@cm_general 
    121       dirnames = ['./', iodir, homedir, !path] 
     123      dirnames = [current, iodir, homedir, !path] 
    122124      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] 
    124127      IF tstdtadir NE '' THEN dirnames = [tstdtadir, dirnames] 
    125128    END 
    126129    keyword_set(iodirectory): dirnames = iodirectory 
    127130    keyword_set(repertoire): dirnames = repertoire 
    128     ELSE: dirnames = ['./', !path] 
     131    ELSE: dirnames = [current, !path] 
    129132  ENDCASE 
    130133  tmp = dirnames 
  • trunk/SRC/Utilities/mergeonline_help.pro

    r231 r239  
    154154  homehtml = strsed(homehtml, 'src=\"', 'src="'+homeidl) 
    155155; 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"') 
    157158; 
    158159  putfile, homesrc + 'home.html', temporary(homehtml) 
     
    160161; build homesrc + 'aboutsaxo.txt' 
    161162;--------------------------------------------------------------- 
    162   about = getfile(homesaxo + '../../overview') 
     163  about = getfile(homesaxo + parent + parent + 'overview') 
    163164; remove the lines containing @ 
    164165  lines = strmatch(about, '@*') 
  • trunk/SRC/Utilities/report.pro

    r232 r239  
    6969  res = -1                      ; 
    7070; we separate the text in different lines (separated by !C) if it is not already done... 
    71    if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim) 
     71  if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim) 
    7272; there is some widgets activated, it is easy, we call dialog_massage 
    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 
     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 
    7878; there is not any widget activated 
    7979; do we ask a question ? 
    80       if keyword_set(question) then BEGIN 
     80    if keyword_set(question) then BEGIN 
    8181; what i sthe answer by default ? 
    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) ; 
     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) ; 
    8888; if the answer is not appropriated 
    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               ; 
     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                  ; 
    9393; 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 
    100101; 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       ENDELSE 
    106    ENDELSE 
     102  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 
    107108 
    108109   return,  res 
  • trunk/SRC/Utilities/xfile.pro

    r232 r239  
    33; @file_comments 
    44; display in a widget an ASCII file. 
    5 ; It is the same thing that xdisplayfile but here, we use it 
    6 ; 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. 
    88; 
    99; @categories 
     
    1515; 
    1616; @keyword _EXTRA 
    17 ; Used to pass keywords 
     17; Used to pass keywords to <proidl>xdisplayfile</proidl> 
    1818; 
    1919; @examples 
     
    3434  compile_opt idl2, strictarrsubs 
    3535; 
    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 
    6547   return 
    6648end 
  • trunk/SRC/Utilities/xhelp.pro

    r232 r239  
    99; @param FILENAME {in}{required} 
    1010; 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. 
    1513; 
    1614; @keyword _EXTRA 
    17 ; Used to pass keywords 
     15; Used to pass keywords to <proidl>xdisplayfile</proidl> 
    1816; 
    1917; @restrictions 
     
    4543 
    4644; Are we sure filename is a string? 
    47    cquoidonc = size(filename, /type) 
    48    if cquoidonc NE 7 then begin 
    49       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)) 
    5048      return 
    5149   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 ...') 
    10285 
    10386   return 
Note: See TracChangeset for help on using the changeset viewer.