Creating Graphical User Interfaces    

Output Function

The output function returns output arguments to the command line. This is particularly useful if you want to return a variable to another GUI. For an example, see Example: Using the Modal Dialog to Confirm an Operation.

GUIDE generates the following lines of code in the output function:

If the GUI is not blocking - in other words, if the M-file does not contain the command uiwait - the output is simply the handle to the GUI, which is assigned to handles.output in the opening function.

To make the GUI return a different output - for example, if you want it to return the result of a user response, such as pressing a push button - do the following:

For example, if the GUI contains a push button whose String property is 'Yes', add the following code to its callback to make the GUI return 'Yes' when the user presses the push button:

See the section Managing GUI Data with the Handles Structure for more information about passing data with the handles structure.

When the GUI is called with the command

and a user presses the Yes push button, the GUI returns the output
OUT = 'Yes' to the command line.

The output varargout, which is a cell array, can contain any number of output arguments. By default, GUIDE creates just one output argument, handles.output. To create another output argument, add the command

to the output function. You can set the value of handles.second_output in any callback and then save it with the guidata command.

If you want, you can choose more descriptive names than output or second_output for the fields of the handles structure corresponding to the output arguments.


  Opening Function Callbacks