The following code uses a game saved in a text file in the form 0/8B1/8B1/8B1/1P6B1/1P8/7S2/7S2/1AAAAA1S2/5DDD2
(for example) and puts the correct pieces in a board. The numbers represent a series of consecutive spaces and / means a new row. The letters represent the ship in that cell of the board ( a two dimensional array).
When I run it it come sup with EXTERNAL SIGSEGV and shows me assembly code saying 00403D61 833a00 cmpl $0x0,(%edx)
Does anyone know what is wrong with it and how to fix it?
Procedure LoadGame(FileName : String; Var Board : TBoard);
Var
Line : String;
CurrentFile : Text;
Row , count : Integer;
column, counter: Integer;
Begin
AssignFile(CurrentFile, FileName);
Reset(CurrentFile);
Readln(CurrentFile, Line);
for counter := 1 to length(line) do
begin
if (Line[counter] in ['A'..'Z','m','h']) then
begin
board[row,column]:=line[counter];
column:=column+1;
end
else
if line[counter]='0' then
begin
for column := 0 to 9 do
begin
board[row,column]:='-';
end;
end
else
If line[counter]='/' then
begin
row :=row+1;
column:=0;
end
else
for count := 0 to (strtoint(line[counter])-1) do
begin
Board[row,column+count] :='-';
column:=column+1;
end;
end;
CloseFile(CurrentFile);
End;
rowandcolumnvariables which changes in chaotic ways (for the first glance) inside the main loop. - Abelisto