Changeset 485 for trunk/SRC/Utilities/report.pro
- Timestamp:
- 08/02/13 18:25:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Utilities/report.pro
r375 r485 25 25 ; @keyword QUESTION {default="Warning"} 26 26 ; Set this keyword to create a "Question" dialog. 27 ; If batch mode is detected, answer to be given is ANSWER_BATCH if exists or 28 ; the default one (see DEFAULT_NO keyword). 29 ; 30 ; @keyword ANSWER_BATCH 31 ; Answer to be given to replace human being when running in non interactive 32 ; session. Only used when QUESTION keyword is set. 27 33 ; 28 34 ; @keyword DEFAULT_NO {default="Yes"} … … 52 58 ; <Expression> BYTE = 1 53 59 ; 60 ; To simulated non interactive session : 61 ; 62 ; IDL> set_default_device 63 ; IDL> key_batch = 1 64 ; IDL> help, report('question1: !C does it works ?',/question, answer_batch='y') 65 ; question1: 66 ; does it works ? y/n (default answer is y) 67 ; <Expression> BYTE = 1 68 ; 69 ; Like in determineminmax.pro: 70 ; 71 ; set_default_device 72 ; key_batch = 1 73 ; vraimin = 0.d0 74 ; question = ['Warning: constant filed, same value everywhere : ' + strtrim(vraimin, 2) +'!', 'Shall we make the plot?'] 75 ; answer = report(question, /default_no, /question) 76 ; 77 ; 54 78 ; If widgets are already activated, it is the same thing but with widgets! 55 79 ; 56 80 ; @history 57 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 58 ; 21/10/1999 81 ; 82 ; - fplod 20130802T123116Z cratos.locean-ipsl.upmc.fr (Linux) 83 ; 84 ; * add ANSWER_BATCH keyword and handle key_batch 85 ; 86 ; - Sebastien Masson (smasson\@lodyc.jussieu.fr) 21/10/1999 59 87 ; 60 88 ; @version … … 63 91 ;- 64 92 FUNCTION report, textin, DEFAULT_NO=default_no, PARENT=parent $ 65 , QUESTION=question, SIMPLE=simple, _EXTRA=ex 93 , QUESTION=question, SIMPLE=simple $ 94 , ANSWER_BATCH=answer_batch $ 95 , _EXTRA=ex 66 96 ; 67 97 compile_opt idl2, strictarrsubs 98 99 @cm_general 68 100 ; 69 101 res = -1 ; 102 103 ; check parameter and keywords 104 if keyword_set(default_no) then default_answer = 'n' ELSE default_answer = 'y' 105 106 ; if QUESTION keyword is set, ANSWER_BATCH must be also set with value in '', 'y' or 'n' 107 IF keyword_set(QUESTION) THEN BEGIN 108 IF NOT keyword_set(ANSWER_BATCH) THEN BEGIN 109 print, 'www : ANSWER_BATCH is not set, default answer while be used' 110 answer_batch = default_answer 111 ENDIF ELSE BEGIN 112 IF answer_batch NE '' and answer_batch NE 'y' and answer_batch NE 'n' THEN BEGIN 113 answer_batch = default_answer 114 ENDIF 115 ENDELSE 116 ENDIF 117 70 118 ; we separate the text in different lines (separated by !C) if it is not already done... 71 119 if n_elements(textin) EQ 1 then text = '% ' + str_sep(textin, '!C', /trim) ELSE text = '% ' + textin … … 90 138 text = [prefix, text] 91 139 ENDIF 92 ; there is some widgets activated, it is easy, we call dialog_massage140 ; there is some widgets activated, it is easy, we call dialog_massage 93 141 if (widget_info(/managed))[0] NE 0 then BEGIN 94 142 res = dialog_message(text, dialog_parent = parent, QUESTION = question $ … … 96 144 if keyword_set(question) THEN res = res EQ 'Yes' ELSE res = -1 97 145 ENDIF ELSE BEGIN 98 ; there is not any widget activated99 ; do we ask a question ?146 ; there is not any widget activated 147 ; do we ask a question ? 100 148 IF keyword_set(question) THEN BEGIN 101 ; what is the answer by default ?149 ; what is the answer by default ? 102 150 if keyword_set(default_no) then answer = 'n' ELSE answer = 'y' 103 151 default_answer = answer 104 152 if n_elements(text) GT 1 THEN $ 105 153 for i = 0, n_elements(text)-2 do print, text[i] 106 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 154 ; 155 ; if non interactive mode has not yet have been tested, do it 156 IF NOT testvar(var = key_batch) THEN BEGIN 157 set_default_device 158 ENDIF 159 if key_batch EQ 0 THEN BEGIN 160 ; if interactive mode is the current one, wait for human being answer ... 161 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 162 ENDIF ELSE BEGIN 163 ; if not, answer with ANSWER_BATCH keyword or the default answer if not set 164 IF testvar(var = answer_batch) THEN BEGIN 165 print, 'batch answer with answer_batch ', answer_batch 166 answer = answer_batch 167 ENDIF ELSE BEGIN 168 print, 'batch answer with default_answer ', default_answer 169 answer = default_answer 170 ENDELSE 171 ENDELSE 172 107 173 answer = strlowcase(answer) ; 108 ; if the answer is not appropriated174 ; if the answer is not appropriated 109 175 while answer NE '' and answer NE 'y' and answer NE 'n' do begin 110 176 read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')', answer 111 177 answer = strlowcase(answer) 112 178 ENDWHILE ; 113 ; we adjust res in function of the answer179 ; we adjust res in function of the answer 114 180 case answer of 115 181 '':res = default_answer EQ 'y'
Note: See TracChangeset
for help on using the changeset viewer.