我有一個將棋盤保存到文本文件的過程。我試圖在保存後重新讀入該程序。當我調用這個過程時,我得到這個錯誤。如何在保存後將棋盤加載到程序中?
代碼,我必須在裝船。
Procedure LoadBoard(Var Board : Tboard);
var
fptr:text;
i,j,x:integer;
line:string;
load:char;
begin
Write('Do you want a load a game? (Enter Y for yes)');
Readln(load);
If (Ord(load) >= 97) and (Ord(load) <= 122)
Then load := Chr(Ord(load) - 32);
if load='Y' then
begin
assignfile(fptr,'SBoard.txt');
reset(fptr);
i:=1;
repeat
readln(fptr,line);
j:=1;
x:=1;
repeat
begin
if (line[x]<>',') and (line[x+1]<>',')
then
begin
Board[i,j][1]:=line[x];
Board[i,j][2]:=line[x+1];
end;
if line[x]=','
then
j:=j+1;
x:=x+1;
end;
until j=9;
i:=i+1;
until i=9;
close(fptr);
end;
end;
與您的訪問違規無關:谷歌「FEN」通常存儲方式職位。它還包含50個移動規則信息,en passent square,誰要移動......以及所有這些都在一行短文中。 (http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) – BitTickler
當你學習如何調試你的程序時,你會節省大量的時間,而不是爲你面對的每一個問題提出一個問題。 – TLama
第一個問題:如果你使用'writeln(fptr,Board [i,j])將你的棋盤狀態保存爲一個文本文件中的多個字符串'爲什麼你要將它們加載到你的2D字符串數組中,而不是直接作爲字符字符串?例如'Board [i,j]:= line;' – SilverWarior