From help-request at octave dot org Thu Jan 20 17:23:02 2005 Subject: Octave's eval function From: "E. Joshua Rigler" To: Help-Octave Date: Thu, 20 Jan 2005 16:23:43 -0700 The following does what I want: out=eval("if (~exist('tmp')) tmp=0; endif; tmp=tmp+1; tmp*5;"); ...specifically, it evaluates the string to 1) initialize the variable tmp if it doesn't already exist; 2) increment tmp by 1 each time it is called; and 3) return tmp*5 to the variable out. Is the fact that eval appears to always return the result of the last expression in the string (i.e., tmp*5) strictly intentional? I can't really tell from the help file. This is exactly what I want, but I just want to be sure this behavior isn't likely to change anytime soon. I'm running 2.1.64 with the latest Forge. Thanks, EJR ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------