1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>I/O Dialogs (GNU Octave (version 4.4.1))</title>
<meta name="description" content="I/O Dialogs (GNU Octave (version 4.4.1))">
<meta name="keywords" content="I/O Dialogs (GNU Octave (version 4.4.1))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="GUI-Development.html#GUI-Development" rel="up" title="GUI Development">
<link href="Progress-Bar.html#Progress-Bar" rel="next" title="Progress Bar">
<link href="GUI-Development.html#GUI-Development" rel="prev" title="GUI Development">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<a name="I_002fO-Dialogs"></a>
<div class="header">
<p>
Next: <a href="Progress-Bar.html#Progress-Bar" accesskey="n" rel="next">Progress Bar</a>, Up: <a href="GUI-Development.html#GUI-Development" accesskey="u" rel="up">GUI Development</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="I_002fO-Dialogs-1"></a>
<h3 class="section">35.1 I/O Dialogs</h3>
<p>Simple dialog menus are available for choosing directories or files. They
return a string variable which can then be used with any command requiring
a filename.
</p>
<a name="index-dialog_002c-displaying-a-dialog-for-selecting-directories"></a>
<a name="XREFuigetdir"></a><dl>
<dt><a name="index-uigetdir"></a><em><var>dirname</var> =</em> <strong>uigetdir</strong> <em>()</em></dt>
<dt><a name="index-uigetdir-1"></a><em><var>dirname</var> =</em> <strong>uigetdir</strong> <em>(<var>init_path</var>)</em></dt>
<dt><a name="index-uigetdir-2"></a><em><var>dirname</var> =</em> <strong>uigetdir</strong> <em>(<var>init_path</var>, <var>dialog_name</var>)</em></dt>
<dd><p>Open a GUI dialog for selecting a directory.
</p>
<p>If <var>init_path</var> is not given the current working directory is used.
</p>
<p><var>dialog_name</var> may be used to customize the dialog title.
</p>
<p><strong>See also:</strong> <a href="#XREFuigetfile">uigetfile</a>, <a href="#XREFuiputfile">uiputfile</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-dialog-for-selecting-files"></a>
<a name="XREFuigetfile"></a><dl>
<dt><a name="index-uigetfile"></a><em>[<var>fname</var>, <var>fpath</var>, <var>fltidx</var>] =</em> <strong>uigetfile</strong> <em>()</em></dt>
<dt><a name="index-uigetfile-1"></a><em>[…] =</em> <strong>uigetfile</strong> <em>(<var>flt</var>)</em></dt>
<dt><a name="index-uigetfile-2"></a><em>[…] =</em> <strong>uigetfile</strong> <em>(<var>flt</var>, <var>dialog_name</var>)</em></dt>
<dt><a name="index-uigetfile-3"></a><em>[…] =</em> <strong>uigetfile</strong> <em>(<var>flt</var>, <var>dialog_name</var>, <var>default_file</var>)</em></dt>
<dt><a name="index-uigetfile-4"></a><em>[…] =</em> <strong>uigetfile</strong> <em>(…, "Position", [<var>px</var> <var>py</var>])</em></dt>
<dt><a name="index-uigetfile-5"></a><em>[…] =</em> <strong>uigetfile</strong> <em>(…, "MultiSelect", <var>mode</var>)</em></dt>
<dd>
<p>Open a GUI dialog for selecting a file and return the filename <var>fname</var>,
the path to this file <var>fpath</var>, and the filter index <var>fltidx</var>.
</p>
<p><var>flt</var> contains a (list of) file filter string(s) in one of the following
formats:
</p>
<dl compact="compact">
<dt><code>"/path/to/filename.ext"</code></dt>
<dd><p>If a filename is given then the file extension is extracted and used as
filter. In addition, the path is selected as current path and the filename
is selected as default file. Example: <code>uigetfile ("myfun.m")</code>
</p>
</dd>
<dt>A single file extension <code>"*.ext"</code></dt>
<dd><p>Example: <code>uigetfile ("*.ext")</code>
</p>
</dd>
<dt>A 2-column cell array</dt>
<dd><p>containing a file extension in the first column and a brief description in
the second column.
Example: <code>uigetfile ({"*.ext", "My Description";"*.xyz",
"XYZ-Format"})</code>
</p>
<p>The filter string can also contain a semicolon separated list of filter
extensions.
Example: <code>uigetfile ({"*.gif;*.png;*.jpg", "Supported Picture
Formats"})</code>
</p>
</dd>
<dt>A directory name or path name</dt>
<dd><p>If the folder name of path name contains a trailing file separator, the
contents of that folder will be displayed. If no trailing file separator
is present the parent directory is listed. The substring to the right of
the rightmost file separator (if any) will be interpreted as a file or
directory name and if that file or directory exists it will be highlighted.
If the path name or directory name is wholly or partly nonexistent, the
current working directory will be displayed.
No filter will be active.
</p></dd>
</dl>
<p><var>dialog_name</var> can be used to customize the dialog title.
</p>
<p>If <var>default_file</var> is given then it will be selected in the GUI dialog.
If, in addition, a path is given it is also used as current path.
</p>
<p>The screen position of the GUI dialog can be set using the
<code>"Position"</code> key and a 2-element vector containing the pixel
coordinates. Two or more files can be selected when setting the
<code>"MultiSelect"</code> key to <code>"on"</code>. In that case <var>fname</var> is a
cell array containing the files.
</p>
<p><strong>See also:</strong> <a href="#XREFuiputfile">uiputfile</a>, <a href="#XREFuigetdir">uigetdir</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-dialog-for-storing-files"></a>
<a name="XREFuiputfile"></a><dl>
<dt><a name="index-uiputfile"></a><em>[<var>fname</var>, <var>fpath</var>, <var>fltidx</var>] =</em> <strong>uiputfile</strong> <em>()</em></dt>
<dt><a name="index-uiputfile-1"></a><em>[<var>fname</var>, <var>fpath</var>, <var>fltidx</var>] =</em> <strong>uiputfile</strong> <em>(<var>flt</var>)</em></dt>
<dt><a name="index-uiputfile-2"></a><em>[<var>fname</var>, <var>fpath</var>, <var>fltidx</var>] =</em> <strong>uiputfile</strong> <em>(<var>flt</var>, <var>dialog_name</var>)</em></dt>
<dt><a name="index-uiputfile-3"></a><em>[<var>fname</var>, <var>fpath</var>, <var>fltidx</var>] =</em> <strong>uiputfile</strong> <em>(<var>flt</var>, <var>dialog_name</var>, <var>default_file</var>)</em></dt>
<dd><p>Open a GUI dialog for selecting a file.
</p>
<p><var>flt</var> contains a (list of) file filter string(s) in one of the following
formats:
</p>
<dl compact="compact">
<dt><code>"/path/to/filename.ext"</code></dt>
<dd><p>If a filename is given the file extension is extracted and used as filter.
In addition the path is selected as current path and the filename is
selected as default file. Example: <code>uiputfile ("myfun.m")</code>
</p>
</dd>
<dt><code>"*.ext"</code></dt>
<dd><p>A single file extension.
Example: <code>uiputfile ("*.ext")</code>
</p>
</dd>
<dt><code>{"*.ext", "My Description"}</code></dt>
<dd><p>A 2-column cell array containing the file extension in the 1st column and
a brief description in the 2nd column.
Example: <code>uiputfile ({"*.ext","My Description";"*.xyz",
"XYZ-Format"})</code>
</p></dd>
</dl>
<p>The filter string can also contain a semicolon separated list of filter
extensions.
Example: <code>uiputfile ({"*.gif;*.png;*.jpg",
"Supported Picture Formats"})</code>
</p>
<p><var>dialog_name</var> can be used to customize the dialog title.
If <var>default_file</var> is given it is preselected in the GUI dialog.
If, in addition, a path is given it is also used as current path.
</p>
<p><strong>See also:</strong> <a href="#XREFuigetfile">uigetfile</a>, <a href="#XREFuigetdir">uigetdir</a>.
</p></dd></dl>
<p>Additionally, there are dialog boxes for printing further help, warnings or
errors and to get textual input from the user.
</p>
<a name="index-dialog_002c-displaying-an-error-dialog"></a>
<a name="XREFerrordlg"></a><dl>
<dt><a name="index-errordlg"></a><em><var>h</var> =</em> <strong>errordlg</strong> <em>()</em></dt>
<dt><a name="index-errordlg-1"></a><em><var>h</var> =</em> <strong>errordlg</strong> <em>(<var>msg</var>)</em></dt>
<dt><a name="index-errordlg-2"></a><em><var>h</var> =</em> <strong>errordlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt>
<dt><a name="index-errordlg-3"></a><em><var>h</var> =</em> <strong>errordlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>createmode</var>)</em></dt>
<dd><p>Display an error dialog box with error message <var>msg</var> and caption
<var>title</var>.
</p>
<p>The default error message is <code>"This is the default error string."</code> and
the default caption is <code>"Error Dialog"</code>.
</p>
<p>The error message may have multiple lines separated by newline characters
("\n"), or it may be a cellstr array with one element for each line.
</p>
<p>The return value <var>h</var> is always 1.
</p>
<p>Compatibility Note: The optional argument <var>createmode</var> is accepted for
<small>MATLAB</small> compatibility, but is not implemented. See <code>msgbox</code> for
details.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">errordlg ("Some fancy error occurred.");
errordlg ("Some fancy error\nwith two lines.");
errordlg ({"Some fancy error", "with two lines."});
errordlg ("Some fancy error occurred.", "Fancy caption");
</pre></div>
<p><strong>See also:</strong> <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-help-dialog"></a>
<a name="XREFhelpdlg"></a><dl>
<dt><a name="index-helpdlg"></a><em><var>h</var> =</em> <strong>helpdlg</strong> <em>()</em></dt>
<dt><a name="index-helpdlg-1"></a><em><var>h</var> =</em> <strong>helpdlg</strong> <em>(<var>msg</var>)</em></dt>
<dt><a name="index-helpdlg-2"></a><em><var>h</var> =</em> <strong>helpdlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt>
<dd><p>Display a help dialog box with help message <var>msg</var> and caption
<var>title</var>.
</p>
<p>The default help message is <code>"This is the default help string."</code> and
the default caption is <code>"Help Dialog"</code>.
</p>
<p>The help message may have multiple lines separated by newline characters
("\n"), or it may be a cellstr array with one element for each line.
</p>
<p>The return value <var>h</var> is always 1.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">helpdlg ("Some helpful text for the user.");
helpdlg ("Some helpful text\nwith two lines.");
helpdlg ({"Some helpful text", "with two lines."});
helpdlg ("Some helpful text for the user.", "Fancy caption");
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-an-input-dialog"></a>
<a name="XREFinputdlg"></a><dl>
<dt><a name="index-inputdlg"></a><em><var>cstr</var> =</em> <strong>inputdlg</strong> <em>(<var>prompt</var>)</em></dt>
<dt><a name="index-inputdlg-1"></a><em><var>cstr</var> =</em> <strong>inputdlg</strong> <em>(<var>prompt</var>, <var>title</var>)</em></dt>
<dt><a name="index-inputdlg-2"></a><em><var>cstr</var> =</em> <strong>inputdlg</strong> <em>(<var>prompt</var>, <var>title</var>, <var>rowscols</var>)</em></dt>
<dt><a name="index-inputdlg-3"></a><em><var>cstr</var> =</em> <strong>inputdlg</strong> <em>(<var>prompt</var>, <var>title</var>, <var>rowscols</var>, <var>defaults</var>)</em></dt>
<dt><a name="index-inputdlg-4"></a><em><var>cstr</var> =</em> <strong>inputdlg</strong> <em>(<var>prompt</var>, <var>title</var>, <var>rowscols</var>, <var>defaults</var>, <var>options</var>)</em></dt>
<dd><p>Return user input from a multi-textfield dialog box in a cell array of
strings, or an empty cell array if the dialog is closed by the Cancel
button.
</p>
<p>Inputs:
</p>
<dl compact="compact">
<dt><var>prompt</var></dt>
<dd><p>A cell array with strings labeling each text field. This input is required.
</p>
</dd>
<dt><var>title</var></dt>
<dd><p>String to use for the caption of the dialog. The default is
<code>"Input Dialog"</code>.
</p>
</dd>
<dt><var>rowscols</var></dt>
<dd><p>Specifies the size of the text fields and can take three forms:
</p>
<ol>
<li> a scalar value which defines the number of rows used for each text field.
</li><li> a vector which defines the individual number of rows used for each text field.
</li><li> 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.
</li></ol>
</dd>
<dt><var>defaults</var></dt>
<dd><p>A list of default values to place in each text fields. It must be a cell
array of strings with the same size as <var>prompt</var>.
</p>
</dd>
<dt><var>options</var></dt>
<dd><p>Not supported, only for <small>MATLAB</small> compatibility.
</p></dd>
</dl>
<p>Example:
</p>
<div class="example">
<pre class="example">prompt = {"Width", "Height", "Depth"};
defaults = {"1.10", "2.20", "3.30"};
rowscols = [1,10; 2,20; 3,30];
dims = inputdlg (prompt, "Enter Box Dimensions", rowscols, defaults);
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-list-dialog"></a>
<a name="XREFlistdlg"></a><dl>
<dt><a name="index-listdlg"></a><em>[<var>sel</var>, <var>ok</var>] =</em> <strong>listdlg</strong> <em>(<var>key</var>, <var>value</var>, …)</em></dt>
<dd><p>Return user inputs from a list dialog box in a vector of selection indices
(<var>sel</var>) and a flag indicating how the user closed the dialog box
(<var>ok</var>).
</p>
<p>The indices in <var>sel</var> are 1-based.
</p>
<p>The value of <var>ok</var> is 1 if the user closed the box with the OK button,
otherwise it is 0 and <var>sel</var> is empty.
</p>
<p>Input arguments are specified in form of <var>key</var>, <var>value</var> pairs.
The <code>"ListString"</code> argument pair must be specified.
</p>
<p>Valid <var>key</var> and <var>value</var> pairs are:
</p>
<dl compact="compact">
<dt><code>"ListString"</code></dt>
<dd><p>a cell array of strings with the contents of the list.
</p>
</dd>
<dt><code>"SelectionMode"</code></dt>
<dd><p>can be either <code>"Single"</code> or <code>"Multiple"</code> (default).
</p>
</dd>
<dt><code>"ListSize"</code></dt>
<dd><p>a vector with two elements <var>width</var> and <var>height</var> defining the size
of the list field in pixels. Default is [160 300].
</p>
</dd>
<dt><code>"InitialValue"</code></dt>
<dd><p>a vector containing 1-based indices of preselected elements.
Default is 1 (first item).
</p>
</dd>
<dt><code>"Name"</code></dt>
<dd><p>a string to be used as the dialog caption. Default is "".
</p>
</dd>
<dt><code>"PromptString"</code></dt>
<dd><p>a cell array of strings to be displayed above the list field.
Default is {}.
</p>
</dd>
<dt><code>"OKString"</code></dt>
<dd><p>a string used to label the OK button. Default is <code>"OK"</code>.
</p>
</dd>
<dt><code>"CancelString"</code></dt>
<dd><p>a string used to label the Cancel button. Default is <code>"Cancel"</code>.
</p></dd>
</dl>
<p>Example:
</p>
<div class="example">
<pre class="example">my_options = {"An item", "another", "yet another"};
[sel, ok] = listdlg ("ListString", my_options,
"SelectionMode", "Multiple");
if (ok == 1)
disp ("You selected:");
for i = 1:numel (sel)
disp (sprintf ("\t%s", my_options{sel(i)}));
endfor
else
disp ("You cancelled.");
endif
</pre></div>
<p><strong>See also:</strong> <a href="Terminal-Input.html#XREFmenu">menu</a>, <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-message-dialog"></a>
<a name="XREFmsgbox"></a><dl>
<dt><a name="index-msgbox"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(<var>msg</var>)</em></dt>
<dt><a name="index-msgbox-1"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt>
<dt><a name="index-msgbox-2"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(<var>msg</var>, <var>title</var>, <var>icon</var>)</em></dt>
<dt><a name="index-msgbox-3"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(…, <var>createmode</var>)</em></dt>
<dd><p>Display <var>msg</var> using a message dialog box.
</p>
<p>The message may have multiple lines separated by newline characters ("\n"),
or it may be a cellstr array with one element for each line.
</p>
<p>The optional input <var>title</var> (character string) can be used to decorate
the dialog caption.
</p>
<p>The optional argument <var>icon</var> selects a dialog icon.
It can be one of <code>"none"</code> (default), <code>"error"</code>, <code>"help"</code>,
or <code>"warn"</code>.
</p>
<p>The return value is always 1.
</p>
<p>Compatibility Note: The optional argument <var>createmode</var> is accepted for
<small>MATLAB</small> compatibility, but is not implemented. A valid <var>createmode</var>
is either one of the character strings <code>"nonmodal"</code>, <code>"modal"</code>,
or <code>"replace"</code>, or a structure containing a field
<code>"WindowStyle"</code> with one of the three character strings.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">msgbox ("Some message for the user.");
msgbox ("Some message\nwith two lines.");
msgbox ({"Some message", "with two lines."});
msgbox ("Some message for the user.", "Fancy caption");
% A message dialog box with error icon
msgbox ("Some message for the user.", "Fancy caption", "error");
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-question-dialog"></a>
<a name="XREFquestdlg"></a><dl>
<dt><a name="index-questdlg"></a><em><var>btn</var> =</em> <strong>questdlg</strong> <em>(<var>msg</var>)</em></dt>
<dt><a name="index-questdlg-1"></a><em><var>btn</var> =</em> <strong>questdlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt>
<dt><a name="index-questdlg-2"></a><em><var>btn</var> =</em> <strong>questdlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>default</var>)</em></dt>
<dt><a name="index-questdlg-3"></a><em><var>btn</var> =</em> <strong>questdlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>btn1</var>, <var>btn2</var>, <var>default</var>)</em></dt>
<dt><a name="index-questdlg-4"></a><em><var>btn</var> =</em> <strong>questdlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>btn1</var>, <var>btn2</var>, <var>btn3</var>, <var>default</var>)</em></dt>
<dd><p>Display <var>msg</var> using a question dialog box and return the caption of
the activated button.
</p>
<p>The message may have multiple lines separated by newline characters ("\n"),
or it may be a cellstr array with one element for each line.
</p>
<p>The optional <var>title</var> (character string) can be used to specify the
dialog caption. It defaults to <code>"Question Dialog"</code>.
</p>
<p>The dialog may contain two or three buttons which will all close the dialog.
</p>
<p>The string <var>default</var> identifies the default button, which is activated
by pressing the <tt class="key">ENTER</tt> key. It must match one of the strings given
in <var>btn1</var>, <var>btn2</var>, or <var>btn3</var>.
</p>
<p>If only <var>msg</var> and <var>title</var> are specified, three buttons with the
default captions <code>"Yes"</code>, <code>"No"</code>, and <code>"Cancel"</code> are used.
</p>
<p>If only two button captions, <var>btn1</var> and <var>btn2</var>, are specified the
dialog will have only these two buttons.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">btn = questdlg ("Close Octave?", "Some fancy title", "Yes", "No", "No");
if (strcmp (btn, "Yes"))
exit ();
endif
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFwarndlg">warndlg</a>.
</p></dd></dl>
<a name="index-dialog_002c-displaying-a-warning-dialog"></a>
<a name="XREFwarndlg"></a><dl>
<dt><a name="index-warndlg"></a><em><var>h</var> =</em> <strong>warndlg</strong> <em>()</em></dt>
<dt><a name="index-warndlg-1"></a><em><var>h</var> =</em> <strong>warndlg</strong> <em>(<var>msg</var>)</em></dt>
<dt><a name="index-warndlg-2"></a><em><var>h</var> =</em> <strong>warndlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt>
<dt><a name="index-warndlg-3"></a><em><var>h</var> =</em> <strong>warndlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>createmode</var>)</em></dt>
<dd><p>Display a warning dialog box with warning message <var>msg</var> and caption
<var>title</var>.
</p>
<p>The default warning message is <code>"This is the default warning string."</code>
and the default caption is <code>"Warning Dialog"</code>.
</p>
<p>The warning message may have multiple lines separated by newline characters
("\n"), or it may be a cellstr array with one element for each line.
</p>
<p>The return value <var>h</var> is always 1.
</p>
<p>Compatibility Note: The optional argument <var>createmode</var> is accepted for
<small>MATLAB</small> compatibility, but is not implemented. See <code>msgbox</code> for
details.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">warndlg ("Some warning text for the user.");
warndlg ("Some warning text\nwith two lines.");
warndlg ({"Some warning text", "with two lines."});
warndlg ("Some warning text for the user.", "Fancy caption");
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFhelpdlg">helpdlg</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>.
</p></dd></dl>
<p>For creating new dialog types, there is a dialog function.
</p>
<a name="index-dialog_002c-displaying-a-modal-dialog"></a>
<a name="XREFdialog"></a><dl>
<dt><a name="index-dialog"></a><em><var>h</var> =</em> <strong>dialog</strong> <em>()</em></dt>
<dt><a name="index-dialog-1"></a><em><var>h</var> =</em> <strong>dialog</strong> <em>("<var>property</var>", <var>value</var>, …)</em></dt>
<dd>
<p>Create an empty modal dialog window to which other uicontrols can be added.
</p>
<p>The dialog box is a figure object with properties as recommended for a
dialog box.
</p>
<p>The default properties differing from a figure are:
</p>
<dl compact="compact">
<dt>buttondownfcn</dt>
<dd><p><code>if isempty (allchild(gcbf)), close (gcbf), endif</code>
</p>
</dd>
<dt>colormap</dt>
<dd><p>[]
</p>
</dd>
<dt>color</dt>
<dd><p>defaultuicontrolbackgroundcolor
</p>
</dd>
<dt>dockcontrols</dt>
<dd><p>off
</p>
</dd>
<dt>handlevisibility</dt>
<dd><p>callback
</p>
</dd>
<dt>integerhandle</dt>
<dd><p>off
</p>
</dd>
<dt>inverthardcopy</dt>
<dd><p>off
</p>
</dd>
<dt>menubar</dt>
<dd><p>none
</p>
</dd>
<dt>numbertitle</dt>
<dd><p>off
</p>
</dd>
<dt>paperpositionmode</dt>
<dd><p>auto
</p>
</dd>
<dt>resize</dt>
<dd><p>off
</p>
</dd>
<dt>windowstyle</dt>
<dd><p>modal
</p>
</dd>
</dl>
<p>Multiple property-value pairs may be specified for the dialog object, but
they must appear in pairs.
</p>
<p>The return value <var>h</var> is a graphics handle to the created figure.
</p>
<p>Example:
</p>
<div class="example">
<pre class="example">## create an empty dialog window titled "Dialog Example"
h = dialog ("name", "Dialog Example");
## create a button (default style)
b = uicontrol (h, "string", "OK",
"position", [10 10 150 40],
"callback", "delete (gcf)");
## wait for dialog to resume or close
uiwait (h);
</pre></div>
<p><strong>See also:</strong> <a href="#XREFerrordlg">errordlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFquestdlg">questdlg</a>, <a href="#XREFwarndlg">warndlg</a>, <a href="Multiple-Plot-Windows.html#XREFfigure">figure</a>, <a href="GUI-Utility-Functions.html#XREFuiwait">uiwait</a>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Progress-Bar.html#Progress-Bar" accesskey="n" rel="next">Progress Bar</a>, Up: <a href="GUI-Development.html#GUI-Development" accesskey="u" rel="up">GUI Development</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|