Saving chess board to text file delphi -
have attempted save chess board text file , have encountered error.
just clarity board variable:
const boarddimension = 8; type tboard = array[1..boarddimension, 1..boarddimension] of string; procedure saveboard(var board : tboard); var fptr:text; i,j:integer; save:char; begin write('do want save game? (enter y yes)'); readln(save); if (ord(save) >= 97) , (ord(save) <= 122) save := chr(ord(save) - 32); if save='y' begin assign(fptr,'sboard.txt'); rewrite(fptr); reset(fptr); := 1 8 begin j := 1 8 begin if j=8 writeln(fptr,board[i,j]) else begin write(fptr,board[i,j]); write(fptr,',') end end; end; close(fptr); end; end;
a screen grab of error. screen grab of line error triggered.
i/o error 105 "file not open output". because code wrong:
rewrite(fptr); reset(fptr);
the call reset
makes file read-only. remove since serves no purpose. call rewrite
creates new file , opens writing.
Comments
Post a Comment