Changeset 277


Ignore:
Timestamp:
09/04/07 14:30:58 (17 years ago)
Author:
smasson
Message:

slight bugfix + nicer print in report, see #65

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Utilities/report.pro

    r269 r277  
    66; To ask a question whose answer is not yes/no, use <pro>xquestion</pro>. 
    77; 
    8 ; @param TEXT {in}{required} {type=scalar string or arrays of string} 
    9 ; If TEXT is a scalar string, we look for the line feed character "!C". 
    10 ; If TEXT is set to an array of strings, each 
     8; @param TEXTIN {in}{required} {type=scalar string or arrays of string} 
     9; If TEXTIN is a scalar string, we look for the line feed character "!C". 
     10; If TEXTIN is set to an array of strings, each 
    1111; array element is displayed as a separate line of text. 
    1212; 
     
    6161;- 
    6262; 
    63 FUNCTION report, text, DEFAULT_NO = default_no, PARENT = parent, QUESTION = question, SIMPLE = simple, _EXTRA = ex 
     63FUNCTION report, textin, DEFAULT_NO = default_no, PARENT = parent, QUESTION = question, SIMPLE = simple, _EXTRA = ex 
    6464; 
    6565  compile_opt idl2, strictarrsubs 
     
    6767  res = -1                      ; 
    6868; we separate the text in different lines (separated by !C) if it is not already done... 
    69   if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim) 
     69  if n_elements(textin) EQ 1 then text = '% ' + str_sep(textin, '!C', /trim) ELSE text = '% ' + textin 
     70; we get the line, routine name ad revision version 
     71  IF NOT keyword_set(simple) THEN BEGIN 
     72;    Look for the revsion in the code of the procedure/function calling this  
     73;    report function (ie the one where an problem was detected) in the first 
     74;    occurence of the form : 
     75;    "; $Id$" 
     76    prefix = routine_name(1) 
     77    split = STRSPLIT(prefix, ' ', /EXTRACT)   
     78    coderoutine = getfile(split[1]) 
     79    idline = (where(stregex(coderoutine, '^; \$Id: .* .* .* .* \$', /boolean) EQ 1))[0] 
     80    IF (idline GT 0) THEN BEGIN 
     81      split = STRSPLIT(coderoutine[idline], ' ', /EXTRACT) 
     82      prefix = '% '+prefix+ ' rev. ' + split[3] + ': ' 
     83    ENDIF ELSE BEGIN 
     84      prefix = '% '+prefix+': ' 
     85    ENDELSE 
     86    text = [prefix, text] 
     87  ENDIF 
    7088; there is some widgets activated, it is easy, we call dialog_massage 
    7189  if (widget_info(/managed))[0] NE 0 then BEGIN 
     
    7694; there is not any widget activated 
    7795; do we ask a question ? 
    78     if keyword_set(question) then BEGIN 
     96    IF keyword_set(question) THEN BEGIN 
    7997; what is the answer by default ? 
    8098      if keyword_set(default_no) then answer = 'n' ELSE answer = 'y' 
    8199      default_answer = answer 
    82100      if n_elements(text) GT 1 THEN $ 
    83         for i = 0, n_elements(text)-2 do print, text[i] 
     101         for i = 0, n_elements(text)-2 do print, text[i] 
    84102      read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 
    85103      answer = strlowcase(answer) ; 
     
    99117; If we do not ask any question, we just make a print 
    100118  IF NOT keyword_set(question) THEN BEGIN 
    101     IF keyword_set(simple) THEN prefix = '' ELSE BEGIN 
    102 ;    Look for the revsion in the code of the procedure/function calling this  
    103 ;    report function (ie the one where an problem was detected) in the first 
    104 ;    occurence of the form : 
    105 ;    "; $Id$" 
    106      split=STRSPLIT(routine_name(1), ' ', /EXTRACT)   
    107      fileroutine=split[1] 
    108      coderoutine = getfile(fileroutine) 
    109      idline = where(stregex(coderoutine,'^; \$Id: .* .* .* .* \$', /boolean) EQ 1, cnt1) 
    110      IF (idline GT 0) THEN BEGIN 
    111        split=STRSPLIT(coderoutine[idline],' ', /EXTRACT) 
    112        revision=split[3] 
    113        prefix = '% '+routine_name(1)+ ' ' + revision + ': ' 
    114      ENDIF ELSE BEGIN 
    115        prefix = '% '+routine_name(1)+': ' 
    116      ENDELSE 
    117     ENDELSE 
    118     IF n_elements(text) GT 1 THEN $ 
    119       for i = 0, n_elements(text)-2 do print, prefix+text[i] 
    120       print, prefix+text[n_elements(text)-1] 
    121     ENDIF 
     119    FOR i = 0, n_elements(text)-1 do print, text[i] 
     120  ENDIF 
    122121 
    123    return,  res 
     122  return,  res 
    124123end 
Note: See TracChangeset for help on using the changeset viewer.