Re: MATRIX PROBLEMS (AGAIN!)

Hi John

Instead of this:
line.each(’,’) { |this_record|
fields << this_record.chomp(",").strip() # read to the end
of the
file into ‘fields’, split into lines and chomp out the delimiter
mat1[r,c] = fields[r,c] # the rows
and
columns in the matrix = rows and columns in fields
c=c+1
n=n+1
if c > 19 then # loops
through
each row/column. At the end of each line where c=19, reset loop onto
next row
with col = 1
c = 1
end
}
which I think is the problem,

try

fields = eval("[" + line + “]”)

this should turn the string into an array which you can iterate over -
this comes from the Hal F. book so it should work.

HTH

Clive