From: Dan on
hey I've made a GUI using GUIDE and automated code in which the user
selects a bunch of preferences and then they are outputted,
preferably to a larger main GUI. So I'm trying to pass the variables
using varargout within the smaller gui's code. The gui is called
'datasource'.

When the preferences are selected I output them using the code

varargout{1}{1} = handles.host;
varargout{1}{2} = handles.user;
varargout{1}{3} = handles.password;
varargout{1}{4} = handles.port;
varargout{1}{5} = handles.source;

so that they are all within one output which is a cell array.
except when i try to open the gui with an output by typing

h = datasource

i get this error message

??? Error using ==> datasource_OutputFcn
Too many output arguments.

Error in ==> gui_mainfcn at 184
[varargout{1:nargout}] = feval(gui_State.gui_OutputFcn,
gui_hFigure, [], gui_Handles);

Error in ==> datasource at 42
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

how do I fix this? have i not set anything else up that i should
have?

-Dan
From: Ramesh Narasimhan on
I have been trying to figure out almost exactly the same problem. I
get that same error as well sometimes, but am not sure why. Have you
figured out how to accomplish this??

-ramesh

an wrote:
>
>
> hey I've made a GUI using GUIDE and automated code in which the
> user
> selects a bunch of preferences and then they are outputted,
> preferably to a larger main GUI. So I'm trying to pass the
> variables
> using varargout within the smaller gui's code. The gui is called
> 'datasource'.
>
> When the preferences are selected I output them using the code
>
> varargout{1}{1} = handles.host;
> varargout{1}{2} = handles.user;
> varargout{1}{3} = handles.password;
> varargout{1}{4} = handles.port;
> varargout{1}{5} = handles.source;
>
> so that they are all within one output which is a cell array.
> except when i try to open the gui with an output by typing
>
> h = datasource
>
> i get this error message
>
> ??? Error using ==> datasource_OutputFcn
> Too many output arguments.
>
> Error in ==> gui_mainfcn at 184
> [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn,
> gui_hFigure, [], gui_Handles);
>
> Error in ==> datasource at 42
> [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
>
> how do I fix this? have i not set anything else up that i should
> have?
>
> -Dan
From: Dan on
yeah I did actually. It's not very obvious. You can find the solution
if you read previous posts in the newsgroup. here's the link to the
one I found that explains fully two ways to do it

dario, "Excanging data among GUI - a solution ?" #, 25 Nov 2005 4:19 am </WebX?50@@.ef1ca44>


But basically the way to do it is to call a function you made within
the mainGUI from the seperate GUI, this will pass handles from the
seperate GUI to the mainGUI through the function. Then in the
function just write a statement that saves the variables you want. I
think that's how they expect you to pass variables from GUI to GUI.
although to be honest I haven't actually had a chance to test this.

hope that helped

-Dan
From: Ramesh Narasimhan on
I will look into your solution but I may have figured it out using
the output function (I think this is different from what you are
saying at least).

The outputFunction that is created in each GUI is what handles
popping output out of a GUI. the problem is that it wants to execute
immediately upon calling the gui before the variables you want output
have a chance to get made/updated, etc through user input. in the
help, they talk about using uiwait to halt execution of the gui until
the user inputs something, but this only works in the very simplest
of cases, when the user has only one thing to input like pushing a
button, since that triggers uiwait to resume. in that case, they
put uiwait in the outputFunction. however, i have discovered that
you can also use uiwait to halt a function's execution until the
figure is destroyed. this is done bu using uiwait(fig#), which waits
until fig# is destroyed to execute. you can use 'gcf' for fig# to
access the current gui's fig#. SO, once my GUI is done getting the
data from the user, they puch a button called "Apply" or "Save".
this function sets the varargout{1} to what I want sent to the
original GUI, i.e. varargout{1} = y

and then closes the current figure (i.e. the spawned GUI). when it
closes the figure, this allows the outputFunction to execute, as the
uiwait is freed by the destruction of the figure, and then it sets
its varargout to what you want.

so if i call my spawned gui with a command like
[yy] = spawnedGUI, from my original GUI, [yy] becomes what
varargout{1} was from the spawned GUI IN the original GUI, i.e. [yy]
= y.

I hope this make sense. I think it is the most intuitive solution,
since it basically is using the output function like advertised with
the only drawback that you have to destroy the GUI before it will
send info back to the original.

Dan wrote:
>
>
> yeah I did actually. It's not very obvious. You can find the
> solution
> if you read previous posts in the newsgroup. here's the link to the
> one I found that explains fully two ways to do it
>
> <a href="/WebX?50@@.ef1ca44">dario, "Excanging data among GUI
- a solution ?" #, 25 Nov 2005 4:19 am</a>
>
>
>
> But basically the way to do it is to call a function you made
> within
> the mainGUI from the seperate GUI, this will pass handles from the
> seperate GUI to the mainGUI through the function. Then in the
> function just write a statement that saves the variables you want.
> I
> think that's how they expect you to pass variables from GUI to GUI.
> although to be honest I haven't actually had a chance to test this.
>
> hope that helped
>
> -Dan
From: Dan on
wow looks like you figured it out. Thanks a lot I'll try that
solution. I tried the uiwait function before but I could never figure
out how to get it to execute when I closed the figure.

-Dan