Useful pascal code Flashcards

1
Q

saving a file

A

procedure SaveAsText(Board: TBoard; WhoseTurn: Char; fileName: string);

var
  savefile: textfile;
  FileNo, RankNo: Integer;
begin
  assignfile(savefile, fileName);
  rewrite(savefile);
  Writeln(savefile, WhoseTurn);
  For RankNo := 1 To BoardDimension Do
  begin
    for FileNo := 1 to BoardDimension do
      Writeln(savefile, Board[RankNo, FileNo]);
  end;
  closefile(savefile);
end;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly