From octave-sources-request at bevo dot che dot wisc dot edu Fri Jan 18 06:41:36 2002 Subject: loading ascii files starting with a digit From: Teemu Ikonen To: octave-sources at bevo dot che dot wisc dot edu Date: Fri, 18 Jan 2002 14:40:41 +0200 --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When loading a file with a matrix of raw ascii numbers with 'load' the data is stored in a variable which is named as the file, but without an extension. If the filename starts with a number like, for example '123data.dat', the variable is then called '123data' which can't be accessed with the Octave parser. Matlab (at least version 6) handles this by prepending an 'X' to the variable name ('X123data'). Attached is a patch which causes similar behavior in Octave. Teemu --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="load-save.cc.patch" *** load-save.cc.orig Fri Jan 18 13:47:21 2002 --- load-save.cc Fri Jan 18 14:27:58 2002 *************** *** 2081,2086 **** --- 2081,2094 ---- int nr = 0; int nc = 0; + // Append 'X' to a variable name starting with a digit + // as in Matlab v6 + if(isdigit(varname[0])) + { + // warning("load: prepending 'X' to a variable name starting with a digit"); + varname = "X" + varname; + } + get_lines_and_columns (is, filename, nr, nc); if (! error_state && nr > 0 && nc > 0) --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="clog.txt" 2002-01-18 Teemu Ikonen * load-save.cc: When loading a file of numbers only an 'X'is prepended to the variable name if the filename starts with a digit. --fdj2RfSjLxBAspz7--