source: trunk/SRC/Utilities/report.pro @ 232

Last change on this file since 232 was 232, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
RevLine 
[2]1;+
2;
[224]3; @file_comments
[232]4; Like <proidl>dialog_message</proidl> if there is already some widget
5; active or like <proidl>message</proidl> if there is not any widget active.
[133]6; To ask a question whose answer is not yes/no,use xquestion.
[2]7;
[224]8; @param TEXT {in}{required}
[136]9; one string or one vector of string. Si le string ne
[226]10; comporte qu''un element, on cherche les eventuels caracteres de
[2]11; retour a la ligne: '!C'. If text is set to an array of strings, each
12; array element is displayed as a separate line of text.
13;
[224]14; @keyword SIMPLE
[136]15; activate to print only the message without the name
16; and the line of the routine (defined by calling routine_name)
[11]17;
[224]18; @keyword _EXTRA
[232]19; Used to pass keywords to <proidl>dialog_message</proidl> and
20; <proidl>message</proidl>
[2]21;
[224]22; @keyword PARENT
[232]23; same as DIALOG_PARENT of <proidl>dialog_message</proidl>
[2]24;
[136]25; @keyword QUESTION {default="Warning"}
26; Set this keyword to create a "Question" dialog.
[2]27;
[136]28; @keyword DEFAULT_NO {default="Yes"}
[224]29; Set this keyword to make the "No" button the default selection for
30; "Question" dialog.
[2]31;
[224]32; @keyword SIMPLE
33; Activate to print the error message without printing the routine name with
[136]34; its full path.
[2]35;
[224]36; @returns
[136]37; -1 if the keyword QUESTION is not activated
[230]38; If the keyword QUESTION is activated, return 1 for yes and 0 for no.
[224]39;
40; @examples
[136]41; If there is not any widget activated:
[2]42;
[136]43; IDL> help, report('toto tata')
44; % $MAIN$: toto tata
45; <Expression>    INT       =       -1
46; IDL> help, report('does it works ?',/question)
47; does it works ? y/n (default answer is y)
48; <Expression>    BYTE      =    1
49; IDL> help, report('question1: !C does it works ?',/question)
50; question1:
51; does it works ? y/n (default answer is y)
52; <Expression>    BYTE      =    1
[2]53;
[133]54; If widgets are already activated, it is the same thing but with widgets!
[2]55;
[224]56; @history
57; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[2]58;                      21/10/1999
[133]59;
[224]60; @version
61; $Id$
[133]62;
[2]63;-
[231]64;
[232]65FUNCTION report, text, DEFAULT_NO = default_no, PARENT = parent, QUESTION = question, SIMPLE = simple, _EXTRA = ex
[114]66;
67  compile_opt idl2, strictarrsubs
68;
[133]69  res = -1                      ;
70; we separate the text in different lines (separated by !C) if it is not already done...
[2]71   if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim)
[133]72; there is some widgets activated, it is easy, we call dialog_massage
[2]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
[133]78; there is not any widget activated
79; do we ask a question ?
[2]80      if keyword_set(question) then BEGIN
[133]81; what i sthe answer by default ?
[2]82         if keyword_set(default_no) then answer = 'n' ELSE answer = 'y'
83         default_answer = answer
84         if n_elements(text) GT 1 THEN $
[224]85          for i = 0, n_elements(text)-2 do print,text[i]
[2]86         read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')' , answer
87         answer = strlowcase(answer) ;
[133]88; if the answer is not appropriated
[2]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               ;
[133]93; we adjust res in function of th answer
[2]94         case answer of
95            '':res = default_answer EQ 'y'
96            'y':res = 1
97            'n':res = 0
98         endcase
99      endif ELSE BEGIN
[133]100; If we do not ask any question, we just make a print
[11]101        IF keyword_set(simple) THEN prefix = '' ELSE prefix = '% '+routine_name(1)+': '
[2]102         if n_elements(text) GT 1 THEN $
[224]103          for i = 0, n_elements(text)-2 do print, prefix+text[i]
[11]104         print, prefix+text[n_elements(text)-1]
[2]105      ENDELSE
106   ENDELSE
107
108   return,  res
109end
Note: See TracBrowser for help on using the repository browser.