Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problems with gui (return of the variable)

Subject: Problems with gui (return of the variable)

From: Jose

Date: 19 Jun, 2009 15:48:01

Message: 1 of 3

Hello everyone, I am running a main program and I want to
insert a gui function to stop it.

It look like very obvious that it cant so complicated, but I have problems with it:

The main program:

clear all
clc
global x

x=1

while 1
hstoprun=uicontrol (gcf,'String','stop','Position',[20,40,60,20],'Callback','stoprun');

if x==0
break
end

end


This is the gui-function.

XXXXXXXXXXXXXXXXx
function stoprun (obj, event, string_arg)
global snrtest

x=0

XXXXXXXXXXXXXXXX


The weird thing is that the gui-function (stoprun) do not return the new value x=0 to the main program.

And therefore the main program don't stop


Any idea, why the new value of x don't return to the main program?

Cheers,

Jose.





When I put this command in a part of my code, I do not know why

Subject: Problems with gui (return of the variable)

From: Jose

Date: 19 Jun, 2009 16:05:19

Message: 2 of 3

"Jose " <jose.l.vega@gmail.com> wrote in message <h1gbvh$bf2$1@fred.mathworks.com>...
> Hello everyone, I am running a main program and I want to
> insert a gui function to stop it.
>
> It look like very obvious that it cant so complicated, but I have problems with it:
>
> The main program:
>
> clear all
> clc
> global x
>
> x=1
>
> while 1
> hstoprun=uicontrol (gcf,'String','stop','Position',[20,40,60,20],'Callback','stoprun');
>
> if x==0
> break
> end
>
> end
>
>
> This is the gui-function.
>
> XXXXXXXXXXXXXXXXx
> function stoprun (obj, event, string_arg)
> global snrtest
>
> x=0
>
> XXXXXXXXXXXXXXXX
>
>
> The weird thing is that the gui-function (stoprun) do not return the new value x=0 to the main program.
>
> And therefore the main program don't stop
>
>
> Any idea, why the new value of x don't return to the main program?
>
> Cheers,
>
> Jose.
>
> Sorry, there is a mistake in my post, global x,
but I have still the same problem.
>
>
>
>

Subject: Problems with gui (return of the variable)

From: Nathan

Date: 19 Jun, 2009 16:26:22

Message: 3 of 3

On Jun 19, 9:05 am, "Jose " <jose.l.v...@gmail.com> wrote:
> "Jose " <jose.l.v...@gmail.com> wrote in message <h1gbvh$bf...@fred.mathworks.com>...
> > Hello everyone, I am running a main program and I want to
> > insert a gui function to stop it.
>
> > It look like very obvious that it cant so complicated, but I have problems with it:
>
> > The main program:
>
> > clear all
> > clc
> > global x
>
> > x=1
>
> > while 1
> > hstoprun=uicontrol (gcf,'String','stop','Position',[20,40,60,20],'Callback','stoprun');
>
> > if x==0
> > break
> > end
>
> > end
>
> > This is the gui-function.
>
> > XXXXXXXXXXXXXXXXx
> > function stoprun (obj, event, string_arg)
> > global snrtest
>
> > x=0
>
> > XXXXXXXXXXXXXXXX
>
> > The weird thing is that the  gui-function (stoprun) do not return the new value x=0 to the main program.
>
> > And therefore the main program don't stop
>
> > Any idea, why the new value of x don't return to the main program?
>
> > Cheers,
>
> > Jose.
>
> > Sorry, there is a mistake in my post, global x,
>
> but I have still the same problem.
>
>
could you put x as a global in there too? (Just off the top of my
head, that's what i see might help)
function stoprun (obj, event, string_arg)
global snrtest x

x=0

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us