<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262006</link>
    <title>MATLAB Central Newsreader - Programmatic GUI</title>
    <description>Feed for thread: Programmatic GUI</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 30 Sep 2009 18:24:02 -0400</pubDate>
      <title>Programmatic GUI</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262006#683769</link>
      <author>Derek Eggiman</author>
      <description>So when one creates a GUI using GUIDE the handle structure is already created and allows the user to add in any variables he should wish and they will be passed from function to function without issue.&lt;br&gt;
&lt;br&gt;
What is the best way to accomplish this in a programmaticaly created GUI (aka without guide). I am aware that global variables would be an option but this seems like a messy way to do things. There is also the option of nested functions that would seem to accomplish the task as well. &lt;br&gt;
&lt;br&gt;
I guess I'm asking what is the best or most commonly accepted practice to accomplish the task of data sharing among functions in a programmaticaly created GUI? Could I implement a handle structure, like that used in guide, that would take user created variables, and how might that be accomplished? Are there any good tutorials out there on programmaticaly created GUIs? Thanks for the reply.</description>
    </item>
    <item>
      <pubDate>Wed, 30 Sep 2009 18:34:03 -0400</pubDate>
      <title>Re: Programmatic GUI</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262006#683773</link>
      <author>Matt Fig</author>
      <description>There are many ways to do what you want, and each probably has some advantages and disadvantages.  There are two approaches here:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/24861&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/24861&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
which do not use globals, and do not store the handles structure with userdata, guidata or any of these.  You may find these techniques useful.  Good luck.</description>
    </item>
    <item>
      <pubDate>Sat, 03 Oct 2009 02:01:04 -0400</pubDate>
      <title>Re: Programmatic GUI</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262006#684341</link>
      <author>Paul Mennen</author>
      <description>&quot;Matt Fig&quot; wrote &lt;br&gt;
&amp;gt;  There are two approaches here:&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/24861&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/24861&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Hi Matt.  I was looking at the GUI examples in your FEX submission mentioned above and I have a question for you about it. In (for example) GUI_11 you have the following:&lt;br&gt;
&lt;br&gt;
function [] = ed_call(varargin)&lt;br&gt;
[h,S] = varargin{[1,3]}; &lt;br&gt;
&lt;br&gt;
My attention was drawn to that, since I happened to be using an older version of Matlab, and this didn't work. I noticed I could get it to work, by adding the &quot;deal&quot; function. That is:&lt;br&gt;
[h,S] = deal(varargin{[1,3]});&lt;br&gt;
&lt;br&gt;
But whether you have the deal function in there or not, isn't this a somewhat cryptic way of calling the function? It seems much more straight forward to replace the two lines above with this single line:&lt;br&gt;
&lt;br&gt;
function ed_call(h,arg2,S)&lt;br&gt;
&lt;br&gt;
Not only does it work across versions, but it seems much clearer as well. You seem to think carefully about your programming style, so I suspect you had a reason for doing it the way you did, although I can't see it.&lt;br&gt;
&lt;br&gt;
~Paul</description>
    </item>
    <item>
      <pubDate>Sat, 03 Oct 2009 03:39:01 -0400</pubDate>
      <title>Re: Programmatic GUI</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262006#684346</link>
      <author>Matt Fig</author>
      <description>&quot;Paul Mennen&quot; &amp;lt;nospam@mennen.org&amp;gt; wrote in message &amp;lt;ha6b90$lj1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Matt Fig&quot; wrote &lt;br&gt;
&amp;gt; &amp;gt;  There are two approaches here:&lt;br&gt;
&amp;gt; &amp;gt; &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/24861&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/24861&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi Matt.  I was looking at the GUI examples in your FEX submission mentioned above and I have a question for you about it. In (for example) GUI_11 you have the following:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function [] = ed_call(varargin)&lt;br&gt;
&amp;gt; [h,S] = varargin{[1,3]}; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My attention was drawn to that, since I happened to be using an older version of Matlab, and this didn't work. I noticed I could get it to work, by adding the &quot;deal&quot; function. That is:&lt;br&gt;
&amp;gt; [h,S] = deal(varargin{[1,3]});&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Yes, I think in versions prior to 7.0, you will get an error here.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; But whether you have the deal function in there or not, isn't this a somewhat cryptic way of calling the function? It seems much more straight forward to replace the two lines above with this single line:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function ed_call(h,arg2,S)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Not only does it work across versions, but it seems much clearer as well. You seem to think carefully about your programming style, so I suspect you had a reason for doing it the way you did, although I can't see it.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks for asking, Paul.  There are several reasons why I use this approach, but first it must be understood that I don't try to say this is the best way above all others.  With that in mind, here are the reasons I arrived at this approach.  &lt;br&gt;
&lt;br&gt;
1.   I like the uniformity - it is visually appealing and easy to remember when writing callbacks that they all have the same argument list (varargin) and first line (the extraction). &lt;br&gt;
2.  Since all the data I use is in one structure, there is no need for a traditional argument list that might change as I add (or backtrack and remove) capabilities to (from) the GUI during development.  I don't have to go back and put an extra argument in the callback property declaration and then in the callback function declaration, all I have to do is extract from the structure the handle or data I need when I need it.&lt;br&gt;
3.  M-Lint drives me nuts with the &quot;the value passed in may not be used.&quot; This is usually in reference to the eventdata argument.  I know I can turn it off, but I write GUIs for multiple machines and different people.  I don't want to be changing their configurations constantly.&lt;br&gt;
4.  I have written automatic GUI M-File generating software which is fairly advanced (and not on the FEX) which would be too hard to implement consistently with multiple arguments.  varargin is absolutely great here.&lt;br&gt;
5.  The usual case is that I don't explicitly extract h from S, so the statement is usually simply:  S = varargin{3}.  I may have gotten lazy on a couple of those example GUIs, but that is OK, someone may learn what varargin{1} is!  ;-)&lt;br&gt;
6.  (As for why not use deal) Some of the GUIs I write are thousands of lines, instrument controlling and data reducing freaks running on older, slower computers loaded with the latest versions of MATLAB.  deal, being an M-File, can be slow at times (not much I know).  I once traced a hang-up I was having to just such a line (it was helping to cause a serial time-out), fixed it to the current system and never looked back.&lt;br&gt;
&lt;br&gt;
Those are just off the top of my head.  If you have any more questions (or suggestions) about the files, feel free to email me about them.  </description>
    </item>
  </channel>
</rss>

