Mercurial > octave
annotate scripts/gui/inputdlg.m @ 24805:e098b0fb11ab stable
inputdlg.m: Avoid crash when prompt and defaults sizes differ (bug #53209).
* inputdlg.m: Validate numel() of prompt and defaults match or emit an error.
author | Philip Nienhuis <prnienhuis@user.sf.net> |
---|---|
date | Fri, 23 Feb 2018 09:48:58 +0100 |
parents | 3ac9f9ecfae5 |
children | c1bedbc14181 |
rev | line source |
---|---|
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
1 ## Copyright (C) 2010-2017 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{cstr} =} inputdlg (@var{prompt}) |
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{cstr} =} inputdlg (@var{prompt}, @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{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}) |
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{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults}) |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
24 ## @deftypefnx {} {@var{cstr} =} inputdlg (@var{prompt}, @var{title}, @var{rowscols}, @var{defaults}, @var{options}) |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
25 ## Return user input from a multi-textfield dialog box in a cell array of |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
26 ## strings, or an empty cell array if the dialog is closed by the Cancel |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
27 ## button. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 ## |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
29 ## Inputs: |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
30 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
31 ## @table @var |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
32 ## @item prompt |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
33 ## A cell array with strings labeling each text field. This input is required. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
34 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
35 ## @item title |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
36 ## String to use for the caption of the dialog. The default is |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
37 ## @qcode{"Input Dialog"}. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
38 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
39 ## @item rowscols |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
40 ## Specifies the size of the text fields and can take three forms: |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
41 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
42 ## @enumerate |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
43 ## @item a scalar value which defines the number of rows used for each text field. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
44 ## |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
45 ## @item a vector which defines the individual number of rows used for each text field. |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
46 ## |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
47 ## @item a matrix which defines the individual number of rows and columns used for each text field. In the matrix each row describes a single text field. The first column specifies the number of input rows to use and the second column specifies the text field width. |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
48 ## @end enumerate |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
49 ## |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
50 ## @item defaults |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
51 ## A list of default values to place in each text fields. It must be a cell |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19952
diff
changeset
|
52 ## array of strings with the same size as @var{prompt}. |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
53 ## |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
54 ## @item options |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
55 ## Not supported, only for @sc{matlab} compatibility. |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 ## @end table |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
57 ## |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
58 ## Example: |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
59 ## |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
60 ## @example |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
61 ## @group |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
62 ## prompt = @{"Width", "Height", "Depth"@}; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
63 ## defaults = @{"1.10", "2.20", "3.30"@}; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
64 ## rowscols = [1,10; 2,20; 3,30]; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
65 ## dims = inputdlg (prompt, "Enter Box Dimensions", rowscols, defaults); |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
66 ## @end group |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
67 ## @end example |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
68 ## |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
69 ## @seealso{errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg} |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 ## @end deftypefn |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
72 function cstr = inputdlg (prompt, varargin) |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
73 |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
74 narginchk (1, 5); |
15709
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
75 |
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
76 if (iscell (prompt)) |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
77 ## Silently extract only char elements |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
78 prompt = prompt(cellfun ("isclass", prompt, "char")); |
15709
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
79 elseif (ischar (prompt)) |
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
80 prompt = {prompt}; |
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
81 else |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
82 error ("inputdlg: PROMPT 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
|
83 endif |
9fee0b741de6
Update Java dialog scrips to latest octave-forge status
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
15625
diff
changeset
|
84 |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
85 title = "Input Dialog"; |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
86 if (nargin > 1) |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
87 if (! ischar (varargin{1})) |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
88 error ("inputdlg: TITLE must be a character string"); |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
89 endif |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
90 title = varargin{1}; |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
91 endif |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
92 |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
93 linespec = 1; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
94 if (nargin > 2) |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
95 linespec = varargin{2}; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
96 endif |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
97 |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
98 defaults = cellstr (cell (size (prompt))); |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
99 if (nargin > 3) |
24805
e098b0fb11ab
inputdlg.m: Avoid crash when prompt and defaults sizes differ (bug #53209).
Philip Nienhuis <prnienhuis@user.sf.net>
parents:
23219
diff
changeset
|
100 if (numel (varargin{3}) != numel (prompt)) |
e098b0fb11ab
inputdlg.m: Avoid crash when prompt and defaults sizes differ (bug #53209).
Philip Nienhuis <prnienhuis@user.sf.net>
parents:
23219
diff
changeset
|
101 error ("inputdlg: number of DEFAULT items must match number of PROMPT items"); |
e098b0fb11ab
inputdlg.m: Avoid crash when prompt and defaults sizes differ (bug #53209).
Philip Nienhuis <prnienhuis@user.sf.net>
parents:
23219
diff
changeset
|
102 endif |
21630
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
103 defaults = varargin{3}; |
b5d9b95d1e1a
Removing Java dialog boxes.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
21178
diff
changeset
|
104 endif |
22636
c44d57c0a925
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22530
diff
changeset
|
105 |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
106 if (nargin > 4) |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
107 warning ("inputdlg: 5th 'options' argument ignored"); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
108 endif |
22636
c44d57c0a925
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22530
diff
changeset
|
109 |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
110 ## specification of text field sizes as in Matlab |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
111 ## Matlab requires a matrix for linespec, not a cell array... |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
112 ## rc = [1,10; 2,20; 3,30]; |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
113 ## c1 c2 |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
114 ## r1 1 10 first text field is 1x10 |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
115 ## r2 2 20 second text field is 2x20 |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
116 ## r3 3 30 third text field is 3x30 |
21171
2935d56203a4
Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
117 if (! isnumeric (linespec)) |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
118 error ("inputdlg: ROWSCOLS must be numeric"); |
21171
2935d56203a4
Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
119 endif |
2935d56203a4
Fix regressions caused by ismatrix definition change (partial fix bug #47036).
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
120 |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
121 if (isscalar (linespec)) |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
122 ## only scalar value in lineTo, copy from linespec and add defaults |
19952
028b2302f940
inputdlg: allow input prompts of varied size, return answer as column vector (Bug 44552)
John Donoghue <john.donoghue@ieee.org>
parents:
19848
diff
changeset
|
123 rowscols = zeros (numel (prompt), 2); |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
124 ## cols |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 rowscols(:,2) = 25; |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
126 rowscols(:,1) = linespec; |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
127 elseif (ismatrix (linespec)) |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
128 if (rows (linespec) == columns (prompt) && columns (linespec) == 2) |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
129 ## (rows x columns) match, copy array linespec |
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
130 rowscols = linespec; |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
131 elseif (isvector (linespec)) |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
132 if (numel (linespec) == numel (prompt)) |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
133 ## only one column in lineTo, copy from vector linespec and add defaults |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
134 rowscols = zeros (numel (prompt), 2); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
135 ## rows from colum vector linespec, columns are set to default |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
136 rowscols(:,2) = 25; |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
137 rowscols(:,1) = linespec(:); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
138 else |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
139 error ("inputdlg: ROWSCOLS vector does not match size of PROMPT"); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
140 endif |
15772
0f1a143e5002
Overhaul scripts/java directory to conform to Octave core.
Rik <rik@octave.org>
parents:
15750
diff
changeset
|
141 else |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
142 error ("inputdlg: ROWSCOLS matrix does not match size of PROMPT"); |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
143 endif |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 else |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
145 ## dunno |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
146 error ("inputdlg: unknown form of ROWSCOLS argument"); |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
147 endif |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
148 rowscols = ceil (rowscols); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
149 |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
150 ## convert numeric values in defaults cell array to strings |
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
151 defs = cellfun (@num2str, defaults, "UniformOutput", false); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 |
19848
9b7ca334a104
Backout cset a9952a647d52 and use __octave_link_enabled__ rather than isguirunning.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
153 if (__octave_link_enabled__ ()) |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
154 cstr = __octave_link_input_dialog__ (prompt, title, rowscols, defs); |
16551
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
155 else |
6ae555fc8c43
Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
16512
diff
changeset
|
156 error ("inputdlg is not available in this version of Octave"); |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
157 endif |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
158 |
15748
54e8c2527a9e
style and doc fixes for newly imported Java package .m files
John W. Eaton <jwe@octave.org>
parents:
15746
diff
changeset
|
159 endfunction |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
160 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
161 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
162 %!demo |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
163 %! disp ('- test inputdlg with prompt and caption only.'); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
164 %! prompt = {'Width', 'Height', 'Depth'}; |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
165 %! dims = inputdlg (prompt, 'Enter Box Dimensions'); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
166 %! if (isempty (dims)) |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
167 %! helpdlg ('Canceled by user', 'Information'); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
168 %! else |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
169 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
170 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
171 %! str2num (dims{2}) * str2num (dims{3}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
172 %! str2num (dims{1}) * str2num (dims{3})); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
173 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', ... |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
174 %! volume, surface), 'Box Dimensions'); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
175 %! endif |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
176 |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
177 %!demo |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
178 %! disp ('- test inputdlg with prescribed scalar (2 lines per text field) and defaults.'); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
179 %! prompt = {'Width', 'Height', 'Depth'}; |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
180 %! default = {'1.1', '2.2', '3.3'}; |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
181 %! rc = 2; |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
182 %! dims = inputdlg (prompt, 'Enter Box Dimensions', rc, default); |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
183 %! if (isempty (dims)) |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
184 %! helpdlg ('Canceled by user', 'Information'); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
185 %! else |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
186 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
187 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
188 %! str2num (dims{2}) * str2num (dims{3}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
189 %! str2num (dims{1}) * str2num (dims{3})); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
190 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', ... |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
191 %! volume, surface), 'Box Dimensions'); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
192 %! endif |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
193 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
194 %!demo |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
195 %! disp ('- test inputdlg with prescribed vector [1,2,3] for # of lines per text field and defaults.'); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
196 %! prompt = {'Width', 'Height', 'Depth'}; |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
197 %! default = {'1.10', '2.10', '3.10'}; |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
198 %! rc = [1,2,3]; % NOTE: must be an array |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
199 %! dims = inputdlg (prompt, 'Enter Box Dimensions', rc, default); |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
200 %! if (isempty (dims)) |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
201 %! helpdlg ('Canceled by user', 'Information'); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
202 %! else |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
203 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
204 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
205 %! str2num (dims{2}) * str2num (dims{3}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
206 %! str2num (dims{1}) * str2num (dims{3})); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
207 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', ... |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
208 %! volume, surface), 'Box Dimensions'); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
209 %! endif |
16512
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
210 |
7f2395651a1c
dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents:
16505
diff
changeset
|
211 %!demo |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
212 %! disp ('- test inputdlg with prescribed row by column sizes and defaults.'); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
213 %! prompt = {'Width', 'Height', 'Depth'}; |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
214 %! default = {'1.10', '2.20', '3.30'}; |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
215 %! rc = [1,10; 2,20; 3,30]; % NOTE: must be an array |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
216 %! dims = inputdlg (prompt, 'Enter Box Dimensions', rc, default); |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
217 %! if (isempty (dims)) |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
218 %! helpdlg ('Canceled by user', 'Information'); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
219 %! else |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
220 %! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
221 %! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
222 %! str2num (dims{2}) * str2num (dims{3}) + ... |
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
223 %! str2num (dims{1}) * str2num (dims{3})); |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
224 %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', ... |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
225 %! volume, surface), 'Box Dimensions'); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21637
diff
changeset
|
226 %! endif |
16933
e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents:
16551
diff
changeset
|
227 |
22530
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
228 %!demo |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
229 %! disp ('- test inputdlg with vector for a single item.'); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
230 %! prompt = {'enter x value'}; |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
231 %! default = {1}; |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
232 %! answer = inputdlg (prompt,'Enter value', [1 10], default); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
233 %! if (isempty (answer)) |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
234 %! helpdlg ('Canceled by user', 'Information'); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
235 %! else |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
236 %! helpdlg (sprintf ('answer = %d', str2num(answer{1})), 'answer'); |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
237 %! endif |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
238 |
db762b9b9b72
inputdlg.m: proper rowcols handling and accept options parameter (bug #49143)
Avinoam Kalma <a.kalma@gmail.com>
parents:
22323
diff
changeset
|
239 %!error inputdlg (1, 2, 3, 4, 5, 6) |
21637
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
240 %!error <PROMPT must be a character string> inputdlg (1) |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
241 %!error <TITLE must be a character string> inputdlg ("msg", 1) |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
242 %!error <ROWSCOLS must be numeric> inputdlg ("msg", "title", "1") |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
243 %!error <ROWSCOLS vector does not match size> |
59ebef9680ef
More cleanup associated with removing Java dialog boxes (cset b5d9b95d1e1a).
Rik <rik@octave.org>
parents:
21630
diff
changeset
|
244 %! inputdlg ({"a1", "a2"}, "title", [1, 2, 3]); |