I am continuing the process of purging eval statements from
my code, but got stuck on another one. Anybody know a way to
avoid eval here? A minimal version of my current code is below.
First, the user gives a file name. Then the name of the most
updated version of a particular routine (which I update
frequently) is returned by the function get_most_recent_func
which finds the name of the most recent .m file with the
base name given by func_basename in the directory func_path.
Finally the most recent function is called (for now using
eval) with FileName as the argument.
In article <fuiqo8$heq$1@fred.mathworks.com>,
jay vaughan <jvaughan5.nospam@gmail.com> wrote:
>I am continuing the process of purging eval statements from
>my code, but got stuck on another one.
func_handle = str2func(func_name);
func_handle(FileName);
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes
"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
<fuiqo8$heq$1@fred.mathworks.com>...
> Hi Matlab folks,
>
> I am continuing the process of purging eval statements
from
> my code, but got stuck on another one. Anybody know a way
to
> avoid eval here? A minimal version of my current code is
below.
>
> First, the user gives a file name. Then the name of the
most
> updated version of a particular routine (which I update
> frequently) is returned by the function
get_most_recent_func
> which finds the name of the most recent .m file with the
> base name given by func_basename in the directory
func_path.
> Finally the most recent function is called (for now using
> eval) with FileName as the argument.
>
> func_basename = 'my_func';
> FileName = uigetfile;
> func_name = get_most_recent_func(func_path,
func_basename);
> eval([func_name '(''' FileName ''')']);
>
>
> Thanks,
> J
str2func did the trick very nicely and tipped me off on a
useful tool for the future.
J
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fuir6s$r1r$1@canopus.cc.umanitoba.ca>...
> In article <fuiqo8$heq$1@fred.mathworks.com>,
> jay vaughan <jvaughan5.nospam@gmail.com> wrote:
> >I am continuing the process of purging eval statements from
> >my code, but got stuck on another one.
>
> >func_basename = 'my_func';
> >FileName = uigetfile;
> >func_name = get_most_recent_func(func_path, func_basename);
> >eval([func_name '(''' FileName ''')']);
>
> func_handle = str2func(func_name);
> func_handle(FileName);
> --
> "Is there any thing whereof it may be said, See, this is
new? It hath
> been already of old time, which was before us." --
Ecclesiastes
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.