annotate scripts/gui/questdlg.m @ 21637:59ebef9680ef

More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a). * NEWS: List errordlg only once in list of Java functions removed. * errordlg.m: Use a single sentence description of function for first documentation paragraph. Correct misspelling of "occurred". Match variable names in code to those in docstring. * helpdlg.m, warndlg.m: Use a single sentence description of function for first documentation paragraph. Match variable names in code to those in docstring. * inputdlg.m: Match variable names in code to those in docstring. Use function name as prefix to all error messages. Use spaces and line wrapping to make %!demos more readable. * listdlg.m: Re-order and rephrase some of docstring. Add more input validation. Add new BIST tests for input validation. * questdlg.m: Re-order some of docstring. Use function name as prefix to all error messages. Eliminate unreachable otherwise statement in switch block. Add new BIST tests for input validation.
author Rik <rik@octave.org>
date Wed, 20 Apr 2016 15:54:37 -0700
parents b5d9b95d1e1a
children bac0d6f07a3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17700
diff changeset
1 ## Copyright (C) 2010, 2013 Martin Hepperle
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
3 ## This file is part of Octave.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
6 ## under the terms of the GNU General Public License as published by
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
8 ## your option) any later version.
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
9 ##
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
13 ## General Public License for more details.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
15746
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
da26f72408a7 update copyright statements in newly added java files
John W. Eaton <jwe@octave.org>
parents: 15709
diff changeset
17 ## <http://www.gnu.org/licenses/>.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
20 ## @deftypefn {} {@var{btn} =} questdlg (@var{msg})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
21 ## @deftypefnx {} {@var{btn} =} questdlg (@var{msg}, @var{title})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
22 ## @deftypefnx {} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{default})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
23 ## @deftypefnx {} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{default})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
24 ## @deftypefnx {} {@var{btn} =} questdlg (@var{msg}, @var{title}, @var{btn1}, @var{btn2}, @var{btn3}, @var{default})
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
25 ## Display @var{msg} using a question dialog box and return the caption of
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
26 ## the activated button.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
28 ## The message may have multiple lines separated by newline characters ("\n"),
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
29 ## or it may be a cellstr array with one element for each line.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
30 ##
21637
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
31 ## The optional @var{title} (character string) can be used to specify the
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
32 ## dialog caption. It defaults to @qcode{"Question Dialog"}.
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
33 ##
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
34 ## The dialog may contain two or three buttons which will all close the dialog.
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
35 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
36 ## The string @var{default} identifies the default button, which is activated
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
37 ## by pressing the @key{ENTER} key. It must match one of the strings given
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
38 ## in @var{btn1}, @var{btn2}, or @var{btn3}.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
40 ## If only @var{msg} and @var{title} are specified, three buttons with the
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
41 ## default captions @qcode{"Yes"}, @qcode{"No"}, and @qcode{"Cancel"} are used.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
43 ## If only two button captions, @var{btn1} and @var{btn2}, are specified the
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
44 ## dialog will have only these two buttons.
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 ##
21630
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
46 ## Examples:
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
47 ##
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
48 ## @example
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
49 ## @group
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
50 ## btn = questdlg ("Close Octave?", "Some fancy title", "Yes", "No", "No");
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
51 ## if (strcmp (btn, "Yes"))
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
52 ## exit ();
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
53 ## endif
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
54 ## @end group
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
55 ## @end example
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
56 ##
b5d9b95d1e1a Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20955
diff changeset
57 ## @seealso{errordlg, helpdlg, inputdlg, listdlg, msgbox, warndlg}
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 ## @end deftypefn
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
60 function btn = questdlg (msg, title = "Question Dialog", varargin)
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
62 if (nargin < 1 || nargin > 6)
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
63 print_usage ();
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
64 endif
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
65
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
66 if (! ischar (msg))
21637
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
67 if (! iscell (msg))
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
68 error ("questdlg: MSG must be a character string or cellstr array");
15709
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
69 endif
21637
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
70
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
71 msg = sprintf ("%s\n", msg{:});
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
72 msg(end) = "";
15709
9fee0b741de6 Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 15625
diff changeset
73 endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
75 if (! ischar (title))
21637
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
76 error ("questdlg: TITLE must be a character string");
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
77 endif
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
78
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
79 options{1} = "Yes"; # button1
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
80 options{2} = "No"; # button2
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
81 options{3} = "Cancel"; # button3
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
82 options{4} = "Yes"; # default
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
83
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
84 defbtn_error_msg = "questdlg: DEFAULT must match one of the button options";
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
85
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
86 switch (numel (varargin))
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
87 case 0
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
88 ## use default default
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
89
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
90 case 1
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
91 ## default button string
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
92 options{4} = varargin{1}; # default
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
93 if (! any (strcmp (options{4}, options(1:3))))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
94 error (defbtn_error_msg);
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
95 endif
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
96
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
97 case 3
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
98 ## two buttons and default button string
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
99 options{1} = varargin{1}; # button1
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
100 options{2} = ""; # not used, no middle button
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
101 options{3} = varargin{2}; # button3
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
102 options{4} = varargin{3}; # default
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
103 if (! any (strcmp (options{4}, options([1 3]))))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
104 error (defbtn_error_msg);
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
105 endif
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
106
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
107 case 4
15772
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
108 ## three buttons and default button string
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
109 options{1} = varargin{1}; # button1
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
110 options{2} = varargin{2}; # button2
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
111 options{3} = varargin{3}; # button3
0f1a143e5002 Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents: 15748
diff changeset
112 options{4} = varargin{4}; # default
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
113 if (! any (strcmp (options{4}, options(1:3))))
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
114 error (defbtn_error_msg);
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
115 endif
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
116
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
117 endswitch
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
19848
9b7ca334a104 Backout cset a9952a647d52 and use __octave_link_enabled__ rather than isguirunning.
Rik <rik@octave.org>
parents: 19799
diff changeset
119 if (__octave_link_enabled__ ())
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
120 btn = __octave_link_question_dialog__ (msg, title, options{1}, options{2},
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
121 options{3}, options{4});
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
122 else
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
123 error ("questdlg is not available in this version of Octave");
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
124 endif
15625
acf0addfc610 include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
15748
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
126 endfunction
54e8c2527a9e style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents: 15746
diff changeset
127
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
128
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
129 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
130 %! disp ('- test questdlg with two buttons');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
131 %! a = questdlg ('Would you like some free money?',...
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
132 %! '$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $',...
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
133 %! 'No', 'Cancel', 'Cancel');
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
134 %! if (strcmp (a, 'No'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
135 %! msgbox ('Suit yourself.', 'Message Box');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
136 %! endif
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
137
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
138 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
139 %! disp ('- test questdlg with message and title only.');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
140 %! a = 'No';
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
141 %! c = 0;
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20852
diff changeset
142 %! while (strcmp (a, 'No') || ! c)
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
143 %! a = questdlg ('Close this Question Dialog?', 'Reductio Ad Absurdum');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
144 %! if (strcmp (a, 'Yes'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
145 %! q = 'Are you sure?';
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20852
diff changeset
146 %! while (strcmp (a, 'Yes') && ! c)
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
147 %! a = questdlg (q, 'Reductio Ad Absurdum');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
148 %! word = ' really';
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
149 %! i = strfind (q, word);
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
150 %! if (isempty (i))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
151 %! i = strfind (q, ' sure');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
152 %! q = [q '!'];
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
153 %! else
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
154 %! word = [word ','];
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
155 %! endif
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
156 %! q = [q(1:i-1) word q(i:end)];
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
157 %! endwhile
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
158 %! endif
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
159 %! if (strcmp (a, 'Cancel'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
160 %! warndlg ('Answer "Yes" or "No".', 'Warning Dialog');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
161 %! a = 'No';
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
162 %! c = 1;
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
163 %! endif
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
164 %! endwhile
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
165 %! msgbox ('Whew!');
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
166
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16505
diff changeset
167 %!demo
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
168 %! disp ('- test questdlg with five inputs');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
169 %! ans = questdlg ('Are you ready Steve?', 'Brian', 'No', 'Uh huh', 'Uh huh');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
170 %! if (! strcmp (ans, 'No'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
171 %! ans = questdlg ('Andy?', 'Brian', 'No', 'Yeah', 'Yeah');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
172 %! if (! strcmp (ans, 'No'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
173 %! ans = questdlg ('Mick?', 'Brian', 'No', 'Okay', 'Okay');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
174 %! if (! strcmp (ans, 'No'))
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
175 %! ans = msgbox ("Well all right, fellas. \n\n Let''s GO!!!!!",...
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
176 %! 'Ballroom Blitz', 'none');
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
177 %! endif
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
178 %! endif
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16551
diff changeset
179 %! endif
21637
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
180
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
181 ## Test input validation
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
182 %!error questdlg ()
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
183 %!error questdlg (1,2,3,4,5,6,7)
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
184 %!error <MSG must be a character string or cellstr array> questdlg (1)
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
185 %!error <TITLE must be a character string> questdlg ("msg", 1)
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
186 %!error <DEFAULT must match one of the button> questdlg ("msg", "title", "ABC")
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
187 %!error <DEFAULT must match one of the button>
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
188 %! questdlg ("msg", "title", "btn1", "btn2", "ABC");
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
189 %!error <DEFAULT must match one of the button>
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
190 %! questdlg ("msg", "title", "btn1", "btn2", "btn3", "ABC");
59ebef9680ef More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents: 21630
diff changeset
191