Index: trunk/SRC/Utilities/report.pro
===================================================================
--- trunk/SRC/Utilities/report.pro	(revision 375)
+++ trunk/SRC/Utilities/report.pro	(revision 485)
@@ -25,4 +25,10 @@
 ; @keyword QUESTION {default="Warning"}
 ; Set this keyword to create a "Question" dialog.
+; If batch mode is detected, answer to be given is ANSWER_BATCH if exists or 
+; the default one (see DEFAULT_NO keyword).
+;
+; @keyword ANSWER_BATCH
+; Answer to be given to replace human being when running in non interactive
+; session. Only used when QUESTION keyword is set.
 ;
 ; @keyword DEFAULT_NO {default="Yes"}
@@ -52,9 +58,31 @@
 ; <Expression>    BYTE      =    1
 ;
+; To simulated non interactive session :
+;
+;   IDL> set_default_device
+;   IDL> key_batch = 1
+;   IDL> help, report('question1: !C does it works ?',/question, answer_batch='y')
+; question1:
+; does it works ? y/n (default answer is y)
+; <Expression>    BYTE      =    1
+;
+; Like in determineminmax.pro:
+;
+;   set_default_device
+;   key_batch = 1
+;   vraimin = 0.d0
+;   question = ['Warning: constant filed, same value everywhere : ' + strtrim(vraimin, 2) +'!', 'Shall we make the plot?']
+;   answer = report(question, /default_no, /question)
+;
+;
 ; If widgets are already activated, it is the same thing but with widgets!
 ;
 ; @history
-; Sebastien Masson (smasson\@lodyc.jussieu.fr)
-;                      21/10/1999
+;
+; - fplod 20130802T123116Z cratos.locean-ipsl.upmc.fr (Linux)
+;
+;   * add ANSWER_BATCH keyword and handle key_batch
+;
+; - Sebastien Masson (smasson\@lodyc.jussieu.fr) 21/10/1999 
 ;
 ; @version
@@ -63,9 +91,29 @@
 ;-
 FUNCTION report, textin, DEFAULT_NO=default_no, PARENT=parent $
-               , QUESTION=question, SIMPLE=simple, _EXTRA=ex
+               , QUESTION=question, SIMPLE=simple $
+               , ANSWER_BATCH=answer_batch $
+               , _EXTRA=ex
 ;
   compile_opt idl2, strictarrsubs
+
+  @cm_general
 ;
   res = -1                      ;
+
+  ; check parameter and keywords
+  if keyword_set(default_no) then default_answer = 'n' ELSE default_answer = 'y'
+
+  ; if QUESTION keyword is set, ANSWER_BATCH must be also set with value in '', 'y' or 'n'
+  IF keyword_set(QUESTION) THEN BEGIN
+     IF NOT keyword_set(ANSWER_BATCH) THEN BEGIN
+        print, 'www : ANSWER_BATCH is not set, default answer while be used'
+        answer_batch = default_answer
+     ENDIF ELSE BEGIN
+         IF answer_batch NE '' and answer_batch NE 'y' and answer_batch NE 'n' THEN BEGIN
+             answer_batch = default_answer
+         ENDIF
+     ENDELSE
+  ENDIF
+
 ; we separate the text in different lines (separated by !C) if it is not already done...
   if n_elements(textin) EQ 1 then text = '% ' + str_sep(textin, '!C', /trim) ELSE text = '% ' + textin
@@ -90,5 +138,5 @@
     text = [prefix, text]
   ENDIF
-; there is some widgets activated, it is easy, we call dialog_massage
+  ; there is some widgets activated, it is easy, we call dialog_massage
   if (widget_info(/managed))[0] NE 0 then BEGIN
     res = dialog_message(text, dialog_parent = parent, QUESTION = question $
@@ -96,20 +144,38 @@
     if keyword_set(question) THEN res = res EQ 'Yes' ELSE res = -1
   ENDIF ELSE BEGIN
-; there is not any widget activated
-; do we ask a question ?
+    ; there is not any widget activated
+    ; do we ask a question ?
     IF keyword_set(question) THEN BEGIN
-; what is the answer by default ?
+      ; what is the answer by default ?
       if keyword_set(default_no) then answer = 'n' ELSE answer = 'y'
       default_answer = answer
       if n_elements(text) GT 1 THEN $
          for i = 0, n_elements(text)-2 do print, text[i]
-      read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer
+      ;
+      ; if non interactive mode has not yet have been tested, do it
+      IF NOT testvar(var = key_batch) THEN BEGIN
+         set_default_device
+      ENDIF
+      if key_batch EQ 0 THEN BEGIN
+          ; if interactive mode is the current one, wait for human being answer ...
+          read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer
+      ENDIF ELSE BEGIN
+          ; if not, answer with ANSWER_BATCH keyword or the default answer if not set
+          IF testvar(var = answer_batch) THEN BEGIN
+              print, 'batch answer with answer_batch ', answer_batch
+              answer = answer_batch
+          ENDIF ELSE BEGIN
+              print, 'batch answer with default_answer ', default_answer
+              answer = default_answer
+          ENDELSE
+      ENDELSE
+ 
       answer = strlowcase(answer) ;
-; if the answer is not appropriated
+      ; if the answer is not appropriated
       while answer NE '' and answer NE 'y' and answer NE 'n' do begin
         read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer
         answer = strlowcase(answer)
       ENDWHILE                  ;
-; we adjust res in function of the answer
+      ; we adjust res in function of the answer
       case answer of
         '':res = default_answer EQ 'y'
