help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with reading lists


From: John W. Eaton
Subject: Re: Problem with reading lists
Date: Wed, 9 Mar 2005 10:06:52 -0500

On  9-Mar-2005, Quentin Spencer <address@hidden> wrote:

| I think this patch may be all that is necessary. I've never used 
| textread--does someone want to test it?
| 
| --- octave-forge/main/io/textread.m     2003-09-12 09:22:42.000000000 -0500
| +++ textread.m  2005-03-09 08:33:16.329991968 -0600
| @@ -122,7 +122,7 @@
|    cat = setstr(cat);
|    for i=1:length(cat)
|      if cat(i) == "s"
| -      eval(sprintf("a%d=list();",i));
| +      eval(sprintf("a%d={};",i));
|      elseif cat(i) == "c"
|        eval(sprintf("a%d="";", i));
|      else
| @@ -167,7 +167,7 @@
|                     format(idx(i):idx(i+1)-1),row,i);
|         endif
|          if (cat(i) == "s") # list of strings
| -         eval(sprintf("a%d = append(a%d, data);", i, i));
| +         eval(sprintf("a%d = {a%d{:}, data};", i, i));
|         elseif (cat(i) == "c" )  # matrix of characters
|            eval(sprintf("a%d = [ a%d ; data ];", i, i));
|          else                       # matrix of scalars

Yes, this might be all that is *needed*, but that function would also
be a lot better if it avoided the use of eval.  I don't see why it is
necessasry to use eval to create return values with the names a1, a2,
..., aN, and then use eval again to assign the temporary variables to
varargout{1}, varargout{2}, ..., varargout{N}.  It seems it should be
possbile to do that in one step, without eval.

jwe



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]