<!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 5.1.0))</title> <meta name="description" content="I/O Dialogs (GNU Octave (version 5.1.0))"> <meta name="keywords" content="I/O Dialogs (GNU Octave (version 5.1.0))"> <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 displaying help messages, warnings, or errors, and for getting text 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></em> <strong>errordlg</strong> <em>()</em></dt> <dt><a name="index-errordlg-1"></a><em></em> <strong>errordlg</strong> <em>(<var>msg</var>)</em></dt> <dt><a name="index-errordlg-2"></a><em></em> <strong>errordlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt> <dt><a name="index-errordlg-3"></a><em></em> <strong>errordlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>opt</var>)</em></dt> <dt><a name="index-errordlg-4"></a><em><var>h</var> =</em> <strong>errordlg</strong> <em>(…)</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 third optional argument <var>opt</var> controls the behavior of the dialog. See <code>msgbox</code> for details. </p> <p>The return value <var>h</var> is a handle to the figure object used for building the dialog. </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="#XREFwarndlg">warndlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFquestdlg">questdlg</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></em> <strong>helpdlg</strong> <em>()</em></dt> <dt><a name="index-helpdlg-1"></a><em></em> <strong>helpdlg</strong> <em>(<var>msg</var>)</em></dt> <dt><a name="index-helpdlg-2"></a><em></em> <strong>helpdlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt> <dt><a name="index-helpdlg-3"></a><em><var>h</var> =</em> <strong>helpdlg</strong> <em>(…)</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 a handle to the figure object used for building the dialog. </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="#XREFwarndlg">warndlg</a>, <a href="#XREFmsgbox">msgbox</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</a>, <a href="#XREFquestdlg">questdlg</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 field. 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 <strong>must</strong> 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 specifying the items to list in the dialog. </p> </dd> <dt><code>"SelectionMode"</code></dt> <dd><p>can be either <code>"Single"</code> (only one item may be selected at a time) or <code>"Multiple"</code> (default). </p> </dd> <dt><code>"ListSize"</code></dt> <dd><p>a two-element vector <code>[<var>width</var>, <var>height</var>]</code> specifying the size of the list field in pixels. The default is [160, 300]. </p> </dd> <dt><code>"InitialValue"</code></dt> <dd><p>a vector containing 1-based indices of elements which will be pre-selected when the list dialog is first displayed. The 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 of items. 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>msg</var>, <var>title</var>, "custom", <var>cdata</var>)</em></dt> <dt><a name="index-msgbox-4"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(<var>msg</var>, <var>title</var>, "custom", <var>cdata</var>, <var>colormap</var>)</em></dt> <dt><a name="index-msgbox-5"></a><em><var>h</var> =</em> <strong>msgbox</strong> <em>(…, <var>opt</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>, <code>"warn"</code>, or <code>"custom"</code>. The latter must be followed by an image array <var>cdata</var>, and for indexed images the associated colormap. </p> <p>The final optional argument <var>opt</var> controls the behavior of the dialog. If <var>opt</var> is a string, it may be one of </p> <dl compact="compact"> <dt><code>"non-modal"</code> (default)</dt> <dd><p>The dialog is normal. </p> </dd> <dt><code>"modal"</code></dt> <dd><p>The dialog is displayed <code>"modal"</code> which means it prevents users from interacting with any other GUI element until the dialog has been closed. </p> </dd> <dt><code>"replace"</code></dt> <dd><p>If any dialogs already exist with the same title, the most recent is reused and all others are closed. The resulting dialog is set <code>"non-modal"</code>. </p></dd> </dl> <p>If <var>opt</var> is a structure, it must contain fields <code>"WindowStyle"</code> and <code>"Interpreter"</code>: </p> <dl compact="compact"> <dt><code>"WindowStyle"</code></dt> <dd><p>The value must be <code>"non-modal"</code>, <code>"modal"</code>, or <code>"replace"</code>. See above. </p> </dd> <dt><code>"Interpreter"</code></dt> <dd><p>Controls the <code>"interpreter"</code> property of the text object used for displaying the message. The value must be <code>"tex"</code> (default), <code>"none"</code>, or <code>"latex"</code>. </p></dd> </dl> <p>The return value <var>h</var> is a handle to the figure object used for building the dialog. </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></em> <strong>warndlg</strong> <em>()</em></dt> <dt><a name="index-warndlg-1"></a><em></em> <strong>warndlg</strong> <em>(<var>msg</var>)</em></dt> <dt><a name="index-warndlg-2"></a><em></em> <strong>warndlg</strong> <em>(<var>msg</var>, <var>title</var>)</em></dt> <dt><a name="index-warndlg-3"></a><em></em> <strong>warndlg</strong> <em>(<var>msg</var>, <var>title</var>, <var>opt</var>)</em></dt> <dt><a name="index-warndlg-4"></a><em><var>h</var> =</em> <strong>warndlg</strong> <em>(…)</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 third optional argument <var>opt</var> controls the behavior of the dialog. See <code>msgbox</code> for details. </p> <p>The return value <var>h</var> is a handle to the figure object used for building the dialog. </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="#XREFmsgbox">msgbox</a>, <a href="#XREFinputdlg">inputdlg</a>, <a href="#XREFlistdlg">listdlg</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>