Documentation Center

  • Trial Software
  • Product Updates

warndlg

Open warning dialog box

Syntax

h = warndlg
h = warndlg(warningstring)
h = warndlg(warningstring,dlgname)
h = warndlg(warningstring,dlgname,createmode)

Description

h = warndlg displays a dialog box named Warning Dialog containing the string This is the default warning string. The warndlg function returns the handle of the dialog box in h. The warning dialog box disappears after the user clicks OK.

h = warndlg(warningstring) displays a dialog box with the title Warning Dialog containing the string specified by warningstring. The warningstring argument can be any valid string format – cell arrays are preferred.

To use multiple lines in your warning, define warningstring using either of the following:

  • sprintf with newline characters separating the lines

    warndlg(sprintf('Message line 1 \n Message line 2'))
    
  • Cell arrays of strings

    warndlg({'Message line 1';'Message line 2'})
    

h = warndlg(warningstring,dlgname) displays a dialog box with title dlgname.

h = warndlg(warningstring,dlgname,createmode) specifies whether the warning dialog box is modal or nonmodal. Optionally, it can also specify an interpreter for warningstring and dlgname. The createmode argument can be a string or a structure.

If createmode is a string, it must be one of the values shown in the following table.

createmode ValueDescription
modal

Replaces the warning dialog box having the specified Title, that was last created or clicked on, with a modal warning dialog box as specified. All other warning dialog boxes with the same title are deleted. The dialog box which is replaced can be either modal or nonmodal.

non-modal (default)

Creates a new nonmodal warning dialog box with the specified parameters. Existing warning dialog boxes with the same title are not deleted.

replace

Replaces the warning dialog box having the specified Title, that was last created or clicked on, with a nonmodal warning dialog box as specified. All other warning dialog boxes with the same title are deleted. The dialog box which is replaced can be either modal or nonmodal.

    Note:   A modal dialog box prevents the user from interacting with other windows before responding. To block MATLAB® program execution as well, use the uiwait function.

    If you open a dialog with errordlg, msgbox, or warndlg using 'CreateMode','modal' and a non-modal dialog created with any of these functions is already present and has the same name as the modal dialog, the non-modal dialog closes when the modal one opens.

    For more information about modal dialog boxes, see WindowStyle in the Figure Properties.

If CreateMode is a structure, it can have fields WindowStyle and Interpreter. WindowStyle must be one of the options shown in the table above. Interpreter is one of the strings 'tex' or 'none'. The default value for Interpreter is 'none'.

Examples

The statement

warndlg('Pressing OK will clear memory','!! Warning !!')

displays this dialog box:

See Also

| | | | | | | | | |

Was this topic helpful?