I know it is no good style to use eval and stuff, but
sometimes it is nice. But now it gets me in trouble...
I have created my own versions of disp, display and
fprintf to do some post-processing with my output.
Unfortunately that gets me into trouble if what these
functions would print to the command window is actually
caught be evalc(..). I tried to insert a test using
dbstack() to see whether there is some evalc in the calling
stack but unfortunately it seems like eval and evalc never
appear in the stack (try e.g. "eval('dbstack')" which should
say 'eval' at least but does not).
Does anybody have an idea how to find out whether my
function has been called by evalc or not?
I also thought of using depfun but that seems to not tell
me about this either. Does anybody know another way (except
parsing the calling function's source code)?
thanks
Christian Herdtweck
Subject: how to determine whether called from evalc?
"Christian Herdtweck"
<first_name.last_name@tuebingen.mpg.de> wrote in message
<g2bev1$fia$1@fred.mathworks.com>...
> Hi all you freaks,
>
> I know it is no good style to use eval and stuff, but
> sometimes it is nice. But now it gets me in trouble...
>
> I have created my own versions of disp, display and
> fprintf to do some post-processing with my output.
> Unfortunately that gets me into trouble if what these
> functions would print to the command window is actually
> caught be evalc(..). I tried to insert a test using
> dbstack() to see whether there is some evalc in the calling
> stack but unfortunately it seems like eval and evalc never
> appear in the stack (try e.g. "eval('dbstack')" which should
> say 'eval' at least but does not).
>
> Does anybody have an idea how to find out whether my
> function has been called by evalc or not?
>
> I also thought of using depfun but that seems to not tell
> me about this either. Does anybody know another way (except
> parsing the calling function's source code)?
>
> thanks
> Christian Herdtweck
could you create some intermediate function that sets a
variable saying that you're about to make an eval call, then
you can just check that variable whenever you need it?
Subject: how to determine whether called from evalc?
sorry for the late reply, I was on holidays. Unfortunately
this solution does not work for me because I cannot change
all the code that might call evalc, some of it I do not even
know yet. But thanks a lot anyway
Christian
"Ian Clarkson" <ovoidkumquat@hotmail.com> wrote in message
<g2bh85$bb4$1@fred.mathworks.com>...
> "Christian Herdtweck"
> <first_name.last_name@tuebingen.mpg.de> wrote in message
> <g2bev1$fia$1@fred.mathworks.com>...
> > Hi all you freaks,
> >
> > I know it is no good style to use eval and stuff, but
> > sometimes it is nice. But now it gets me in trouble...
> >
> > I have created my own versions of disp, display and
> > fprintf to do some post-processing with my output.
> > Unfortunately that gets me into trouble if what these
> > functions would print to the command window is actually
> > caught be evalc(..). I tried to insert a test using
> > dbstack() to see whether there is some evalc in the calling
> > stack but unfortunately it seems like eval and evalc never
> > appear in the stack (try e.g. "eval('dbstack')" which should
> > say 'eval' at least but does not).
> >
> > Does anybody have an idea how to find out whether my
> > function has been called by evalc or not?
> >
> > I also thought of using depfun but that seems to not tell
> > me about this either. Does anybody know another way (except
> > parsing the calling function's source code)?
> >
> > thanks
> > Christian Herdtweck
>
> could you create some intermediate function that sets a
> variable saying that you're about to make an eval call, then
> you can just check that variable whenever you need it?
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.