Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: declaring global variables: GUI'S
Date: Mon, 19 Jan 2009 10:52:41 -0500
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <gl27k9$86h$1@fred.mathworks.com>
References: <gktfni$je$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1232380361 8401 144.212.105.187 (19 Jan 2009 15:52:41 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 19 Jan 2009 15:52:41 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
Xref: news.mathworks.com comp.soft-sys.matlab:512485



"simon ott" <simon_ott@yahoo.com> wrote in message 
news:gktfni$je$1@fred.mathworks.com...
>
> Hello,
> I want to declare global variables so that I could access them from my 
> different GUI's. I declared then in OpeningFcn of every GUI.
>
> function Prog_OpeningFcn(hObject, eventdata, handles, varargin)
> global A
> global A
>
> but I still can not eccess them
> some hint please ?

If you declare a variable as global, then you must declare it as global in 
EVERY function in which you want to access it via the global workspace. 
That means that you will need to declare A as global in every callback 
function that wants to use this variable in each of your GUIs.  It also 
means that if someone else's function uses A as a global variable then they 
can potentially interfere with the operation of your GUI by changing A 
without your GUI functions' knowledge.  For these reasons and others, using 
global variables is discouraged.  Instead, you could store your data in the 
handles structures for your GUIs (and give other GUI functions access to 
those handles structures if they need access to the data in a particular 
GUI), to store them in the UserData for your GUI, etc.

Look at these pages from the documentation for other techniques you can use 
to share data between callbacks and between GUIs:

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/brq3263.html

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-1002439.html

-- 
Steve Lord
slord@mathworks.com