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

Last change on this file since 72 was 11, checked in by pinsard, 18 years ago

upgrade of UTILITAIRE/Utilities according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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   res = -1                     ;
63; on separe le texte en differentes lignes (separees par !C) si ce
64; n''est pas deja fait...
65   if n_elements(text) EQ 1 then text = str_sep(text, '!C', /trim)
66; il y a des widgets actifs, c''est facile on appelle dialog_massage
67   if (widget_info(/managed))[0] NE 0 then BEGIN
68      res = dialog_message(text, dialog_parent = parent, QUESTION = question $
69                           , title = routine_name(1), DEFAULT_NO = default_no, _extra = ex)
70      if keyword_set(question) THEN res = res EQ 'Yes' ELSE res = -1
71   ENDIF ELSE BEGIN
72; aucun widget n''est actif
73; on pose une question ?
74      if keyword_set(question) then BEGIN
75; quelle est la reponse par defaut ?
76         if keyword_set(default_no) then answer = 'n' ELSE answer = 'y'
77         default_answer = answer
78         if n_elements(text) GT 1 THEN $
79          for i = 0, n_elements(text)-2 do print,text[i]
80         read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')' , answer
81         answer = strlowcase(answer) ;
82; si la reponse ne convient pas
83         while answer NE '' and answer NE 'y' and answer NE 'n' do begin
84            read, text[n_elements(text)-1]+' y/n (default answer is '+default_answer+')' , answer
85            answer = strlowcase(answer)
86         ENDWHILE               ;
87; on ajuste res en fonction de la reponse
88         case answer of
89            '':res = default_answer EQ 'y'
90            'y':res = 1
91            'n':res = 0
92         endcase
93      endif ELSE BEGIN
94; si on ne pose pas de question on fait juste un print
95        IF keyword_set(simple) THEN prefix = '' ELSE prefix = '% '+routine_name(1)+': '
96         if n_elements(text) GT 1 THEN $
97          for i = 0, n_elements(text)-2 do print, prefix+text[i]
98         print, prefix+text[n_elements(text)-1]
99      ENDELSE
100   ENDELSE
101
102   return,  res
103end
Note: See TracBrowser for help on using the repository browser.