source: trunk/SRC/ToBeReviewed/UTILITAIRE/report.pro @ 114

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:report
6;
7; PURPOSE: comme dialog_message.pro si il y a deja des widgets actives
8; ou comme message.pro si il n''y a pas de widgets actives. pour poser
9; des question dont la reponse n''est pas oui/non utiliser xquestion
10;
11; CATEGORY:
12;
13; CALLING SEQUENCE:res = report(text)
14;
15; INPUTS: text: un string on un vecteur de string. Si le string ne
16; comporte qu''un element, on cherche les eventuels characteres de
17; retour a la ligne: '!C'. If text is set to an array of strings, each
18; array element is displayed as a separate line of text.
19;
20; KEYWORD PARAMETERS:
21;         SIMPLE: activate to print only the message without the name
22;             and the line of the routine (defined by calling routine_name)
23;
24; ceux dialog_message.pro et message.pro avec en +
25; PARENT qui fait la meme chose que DIALOG_PARENT de dialog_message.pro
26;
27; OUTPUTS: -1 si le mot cle QUESTION n''est pas activer
28;          si le mot cle est active la fonction retourne 1 pour yes et
29;          0 pour no.
30;
31; COMMON BLOCKS:
32;
33; SIDE EFFECTS:
34;
35; RESTRICTIONS:
36;
37; EXAMPLE:
38;
39; si aucun widget n''est active:
40;
41;     IDL> help, report('toto tata')
42;     % $MAIN$: toto tata
43;     <Expression>    INT       =       -1
44;     IDL> help, report('ca marche ?',/question)
45;     ca marche ? y/n (default answer is y)
46;     <Expression>    BYTE      =    1
47;     IDL> help, report('question1: !C ca marche ?',/question)
48;     question1:
49;     ca marche ? y/n (default answer is y)
50;     <Expression>    BYTE      =    1
51;
52; si des widgets sont deja actives, c''est la meme chose mais avec des
53; widgets!
54;
55; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
56;                      21/10/1999
57;-
58;------------------------------------------------------------
59;------------------------------------------------------------
60;------------------------------------------------------------
61FUNCTION report, text, DEFAULT_NO = default_no, PARENT = parent, QUESTION = question, SIMPLE = simple, _extra = ex
62;
63  compile_opt idl2, strictarrsubs
64;
65   res = -1                     ;
66; on separe le texte en differentes lignes (separees par !C) si ce
67; n''est pas deja fait...
68   if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim)
69; il y a des widgets actifs, c''est facile on appelle dialog_massage
70   if (widget_info(/managed))[0] NE 0 then BEGIN
71      res = dialog_message(text, dialog_parent = parent, QUESTION = question $
72                           , title = routine_name(1), DEFAULT_NO = default_no, _extra = ex)
73      if keyword_set(question) THEN res = res EQ 'Yes' ELSE res = -1
74   ENDIF ELSE BEGIN
75; aucun widget n''est actif
76; on pose une question ?
77      if keyword_set(question) then BEGIN
78; quelle est la reponse par defaut ?
79         if keyword_set(default_no) then answer = 'n' ELSE answer = 'y'
80         default_answer = answer
81         if n_elements(text) GT 1 THEN $
82          for i = 0, n_elements(text)-2 do print,text[i]
83         read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')' , answer
84         answer = strlowcase(answer) ;
85; si la reponse ne convient pas
86         while answer NE '' and answer NE 'y' and answer NE 'n' do begin
87            read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')' , answer
88            answer = strlowcase(answer)
89         ENDWHILE               ;
90; on ajuste res en fonction de la reponse
91         case answer of
92            '':res = default_answer EQ 'y'
93            'y':res = 1
94            'n':res = 0
95         endcase
96      endif ELSE BEGIN
97; si on ne pose pas de question on fait juste un print
98        IF keyword_set(simple) THEN prefix = '' ELSE prefix = '% '+routine_name(1)+': '
99         if n_elements(text) GT 1 THEN $
100          for i = 0, n_elements(text)-2 do print, prefix+text[i]
101         print, prefix+text[n_elements(text)-1]
102      ENDELSE
103   ENDELSE
104
105   return,  res
106end
Note: See TracBrowser for help on using the repository browser.