Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: : [ ] function?
References: <g5sevj$ra1$1@fred.mathworks.com>
Message-ID: <muyr69n6p5i.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:dQ3buB6PKWadm3EanMmZ6zQYpsw=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 41
Date: Mon, 21 Jul 2008 14:57:45 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1216665922 155.34.163.114 (Mon, 21 Jul 2008 14:45:22 EDT)
NNTP-Posting-Date: Mon, 21 Jul 2008 14:45:22 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:480739



"ching l" <chinglnc@hotmail.com> writes:

> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muyvdyz6qse.fsf@G99-Boettcher.llan.ll.mit.edu>...
>> "ching l" <chinglnc@hotmail.com> writes:
>> 
>> >
>> >
>> > Did I miss something? That's what I did but nothing
>> > happened....did you mean this?
>> >
>> > function answer_nochange_Callback(hObject, eventdata, handles)
>> >
>> > a= [1, 2, 3];
>> 
>> Yes, I mean this.  And it does exactly what you told it to.  It
>> creates a variable "a" in the workspace of the callback function.
>> Now go back to what you did before to store "randValue", so that it
>> would be accessible from one callback to the next.
>> 
>> Do you get that's why you have to do all that stuff with handles and
>> guidata?  Like all functions, once the callback function exits, all
>> its variables disappear.  When you want data to persist, you have to
>> do something else with it.  And the most natural thing when you're
>> writing a GUI is to associate your persistent data with the GUI
>> itself, which is exactly what "handles" and "guidata" are for.
>> 
>> Now take that code that someone else helped you with and
>> extend the
>> concept to this other stuff you'd like to do now.
>> 
>> -Peter
>
> my problem is, it doesnt do this- "It creates a variable "a"
> in the workspace of the callback function"...

Why do you think it doesn't?  Like I explain above, the variable is
created, then the callback function exits and the variable immediately
disappears.

-Peter