hi all
I have this problem. I am trying to write to a file useing a 2d array
in a loop but I keep getting a type mismatch error
the procedures are below.
the type mismatch error I get when compiling is at the line
write(datas,datastring[a1,b1]);
in the save procedure
and the same type mismatch erro in the load procedure at
line
read(datas,datastring[a11,b11]);
does this mean that a 2d array cannot be writen to file ?
I have set the varables for both of the files the same type as the
array ... I was wondering if the file varable has to be defined
diferently since it is a 2d array of string ?
does any kind sould know where I am going wrong ?
I would be eternaly in your debt if you could help me with this one
thanks in advance
var
datas : file of string;
crf : file of integer;
stp : string;
a,b,c,cols,rows,rloop,cloop : integer;
procedure save;
var
a1 : integer;
b1 : integer;
begin
assign(crf,'c:/crinfo.wap');
rewrite(crf);
write(crf,cols);
write(crf,rows);
close(crf);
assign(datas,'c:/pasdem.wap');
rewrite(datas);
for a1 := 1 to rows do
begin
for b1 := 1 to cols do
begin
write(datas,datastring[a1,b1]);
end;
end;
close(datas);
end;
procedure load;
var
a11,b11 : integer;
begin
assign(crf,'c:/crinfo.wap');
reset(crf);
while not eof(crf) do
begin
read(crf,cols);
read(crf,rows);
end;
close(crf);
assign(datas,'c:/pasdem.wap');
reset(datas);
while not eof(datas) do
begin
for a11 := 1 to rows do
begin
for b11 := 1 to cols do
begin
read(datas,datastring[a11,b11]);
end;
end;
end;
close(datas);
end;
thanks again