<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168003</link>
    <title>MATLAB Central Newsreader - eval begone!  (part 2)</title>
    <description>Feed for thread: eval begone!  (part 2)</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The 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>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 21 Apr 2008 19:43:04 -0400</pubDate>
      <title>eval begone!  (part 2)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168003#428055</link>
      <author>jay vaughan</author>
      <description>Hi Matlab folks,&lt;br&gt;
&lt;br&gt;
I am continuing the process of purging eval statements from&lt;br&gt;
my code, but got stuck on another one. Anybody know a way to&lt;br&gt;
avoid eval here? A minimal version of my current code is below.&lt;br&gt;
&lt;br&gt;
First, the user gives a file name. Then the name of the most&lt;br&gt;
updated version of a particular routine (which I update&lt;br&gt;
frequently) is returned by the function get_most_recent_func &lt;br&gt;
which finds the name of the most recent .m file with the&lt;br&gt;
base name given by func_basename in the directory func_path.&lt;br&gt;
Finally the most recent function is called (for now using&lt;br&gt;
eval) with FileName as the argument.&lt;br&gt;
&lt;br&gt;
func_basename = 'my_func';&lt;br&gt;
FileName = uigetfile;&lt;br&gt;
func_name = get_most_recent_func(func_path, func_basename);&lt;br&gt;
eval([func_name '(''' FileName ''')']);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
J&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 21 Apr 2008 19:50:52 -0400</pubDate>
      <title>Re: eval begone!  (part 2)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168003#428057</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fuiqo8$heq$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
jay vaughan &amp;lt;jvaughan5.nospam@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;I am continuing the process of purging eval statements from&lt;br&gt;
&amp;gt;my code, but got stuck on another one.&lt;br&gt;
&lt;br&gt;
&amp;gt;func_basename = 'my_func';&lt;br&gt;
&amp;gt;FileName = uigetfile;&lt;br&gt;
&amp;gt;func_name = get_most_recent_func(func_path, func_basename);&lt;br&gt;
&amp;gt;eval([func_name '(''' FileName ''')']);&lt;br&gt;
&lt;br&gt;
func_handle = str2func(func_name);&lt;br&gt;
func_handle(FileName);&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;"Is there any thing whereof it may be said, See, this is new? It hath&lt;br&gt;
&amp;nbsp;&amp;nbsp;been already of old time, which was before us."    -- Ecclesiastes&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 21 Apr 2008 20:02:02 -0400</pubDate>
      <title>Re: eval begone!  (part 2)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168003#428060</link>
      <author>Yi Cao</author>
      <description>"jay vaughan" &amp;lt;jvaughan5.nospam@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fuiqo8$heq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Matlab folks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am continuing the process of purging eval statements &lt;br&gt;
from&lt;br&gt;
&amp;gt; my code, but got stuck on another one. Anybody know a way &lt;br&gt;
to&lt;br&gt;
&amp;gt; avoid eval here? A minimal version of my current code is &lt;br&gt;
below.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; First, the user gives a file name. Then the name of the &lt;br&gt;
most&lt;br&gt;
&amp;gt; updated version of a particular routine (which I update&lt;br&gt;
&amp;gt; frequently) is returned by the function &lt;br&gt;
get_most_recent_func &lt;br&gt;
&amp;gt; which finds the name of the most recent .m file with the&lt;br&gt;
&amp;gt; base name given by func_basename in the directory &lt;br&gt;
func_path.&lt;br&gt;
&amp;gt; Finally the most recent function is called (for now using&lt;br&gt;
&amp;gt; eval) with FileName as the argument.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; func_basename = 'my_func';&lt;br&gt;
&amp;gt; FileName = uigetfile;&lt;br&gt;
&amp;gt; func_name = get_most_recent_func(func_path, &lt;br&gt;
func_basename);&lt;br&gt;
&amp;gt; eval([func_name '(''' FileName ''')']);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; J&lt;br&gt;
&lt;br&gt;
Maybe you can use feval, something like&lt;br&gt;
&lt;br&gt;
feval(func_name,FileName)&lt;br&gt;
&lt;br&gt;
or&lt;br&gt;
&lt;br&gt;
func = str2func(func_name);&lt;br&gt;
func(FileName);&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Yi Cao&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 21 Apr 2008 21:34:02 -0400</pubDate>
      <title>Re: eval begone!  (part 2)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168003#428071</link>
      <author>jay vaughan</author>
      <description>Thanks (again), Walter.&lt;br&gt;
&lt;br&gt;
str2func did the trick very nicely and tipped me off on a&lt;br&gt;
useful tool for the future.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
J&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in&lt;br&gt;
message &amp;lt;fuir6s$r1r$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;fuiqo8$heq$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; jay vaughan &amp;lt;jvaughan5.nospam@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;I am continuing the process of purging eval statements from&lt;br&gt;
&amp;gt; &amp;gt;my code, but got stuck on another one.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;func_basename = 'my_func';&lt;br&gt;
&amp;gt; &amp;gt;FileName = uigetfile;&lt;br&gt;
&amp;gt; &amp;gt;func_name = get_most_recent_func(func_path, func_basename);&lt;br&gt;
&amp;gt; &amp;gt;eval([func_name '(''' FileName ''')']);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; func_handle = str2func(func_name);&lt;br&gt;
&amp;gt; func_handle(FileName);&lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt;   "Is there any thing whereof it may be said, See, this is&lt;br&gt;
new? It hath&lt;br&gt;
&amp;gt;   been already of old time, which was before us."    --&lt;br&gt;
Ecclesiastes&lt;br&gt;
&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
