need for help about the redraw map problem

[b][red]This message was edited by yrone at 2004-12-15 7:41:24[/red][/b][hr]
sorry to disturb anyone..but i really don't how to slove this problem
the program (crossword puzzle programme) has shown below:

program testing;
uses wincrt;
const
maxrow= 10;
maxcol= 10;
type
puzzle= array[1..maxrow, 1..maxcol] of char;
var
play, input: puzzle;
endgame: boolean;

procedure DrawMap(var play, input: puzzle);
var
infile: text;
row, col, x, y: integer;
ans: char;
begin
assign(infile,'d:infile01.txt');
reset(infile);
readln(infile, row,col);

for x:= 1 to row do
begin
for y:= 1 to col do
begin
read(infile,play[x,y]);
write('');
write(play[x,y]);
end;
end;
end;

procedure PlayingANY(var play, input: puzzle; var endgame: boolean);
var
row, col, x, y: integer;
ans: char;
begin
clrscr;
DrawMap(play, input);
repeat
writeln('enter the row');
readln(row);
writeln('enter the column');
readln(col);
writeln('enter the answer');
readln(ans);
play[x,y]:= ans;
DrawMap(play, input);
until (endgame= true);
end;

begin
endgame:= false;
PlayingANY(play, input, endgame);
end.

when i run out the program and ask the player to enter the answer
the program cannot replace my answer into the procedure(DrawMap)
how can i solve this problem thx><
i need for all help thank you!
-------------------------------------------------------------------
the file content (original map):
9 9{row,col}
-1"""--
-"-----
-"-2--3
5""""""
-"-"--"
-"-"--"
-"-"--"
---"---
6""""--


Comments

  • : [b][red]This message was edited by yrone at 2004-12-15 7:41:24[/red][/b][hr]
    : sorry to disturb anyone..but i really don't how to slove this problem
    : the program (crossword puzzle programme) has shown below:
    :
    : program testing;
    : uses wincrt;
    : const
    : maxrow= 10;
    : maxcol= 10;
    : type
    : puzzle= array[1..maxrow, 1..maxcol] of char;
    : var
    : play, input: puzzle;
    : endgame: boolean;
    :
    : procedure DrawMap(var play, input: puzzle);
    : var
    : infile: text;
    : row, col, x, y: integer;
    : ans: char;
    : begin
    : assign(infile,'d:infile01.txt');
    : reset(infile);
    : readln(infile, row,col);
    :
    : for x:= 1 to row do
    : begin
    : for y:= 1 to col do
    : begin
    : read(infile,play[x,y]);
    : write('');
    : write(play[x,y]);
    : end;
    : end;
    : end;
    :
    : procedure PlayingANY(var play, input: puzzle; var endgame: boolean);
    : var
    : row, col, x, y: integer;
    : ans: char;
    : begin
    : clrscr;
    : DrawMap(play, input);
    : repeat
    : writeln('enter the row');
    : readln(row);
    : writeln('enter the column');
    : readln(col);
    : writeln('enter the answer');
    : readln(ans);
    : play[x,y]:= ans;
    : DrawMap(play, input);
    : until (endgame= true);
    : end;
    :
    : begin
    : endgame:= false;
    : PlayingANY(play, input, endgame);
    : end.
    :

    : when i run out the program and ask the player to enter the answer
    : the program cannot replace my answer into the procedure(DrawMap)
    : how can i solve this problem thx><
    : i need for all help thank you!
    : -------------------------------------------------------------------
    : the file content (original map):
    : 9 9{row,col}
    : -1"""--
    : -"-----
    : -"-2--3
    : 5""""""
    : -"-"--"
    : -"-"--"
    : -"-"--"
    : ---"---
    : 6""""--
    :
    :
    :
    You only need to read the file once. Then the map is stored in the RAM memory. If the player enters a word, you insert the entered word into the RAM memory map and redraw that.
    Also you forgot the close the file. This might cause complications for large games.

  • : You only need to read the file once. Then the map is stored in the RAM memory. If the player enters a word, you insert the entered word into the RAM memory map and redraw that.
    : Also you forgot the close the file. This might cause complications for large games.
    :
    but i need to repeat redraw the map until player enter all the answer
    how can i do this.
    can you tell me more in detail?!thank you.
    o..i see i forgotten to close the file.
  • :
    : : You only need to read the file once. Then the map is stored in the RAM memory. If the player enters a word, you insert the entered word into the RAM memory map and redraw that.
    : : Also you forgot the close the file. This might cause complications for large games.
    : :
    : but i need to repeat redraw the map until player enter all the answer
    : how can i do this.
    : can you tell me more in detail?!thank you.
    : o..i see i forgotten to close the file.
    :
    In DrawMap() you reload Play[] every time. This means that the addition of the answer is lost, every time DrawMap() is called. The solution is to remove the file-read from that procedure and create a new one LoadMap(), which does nothing but load the map. This procedure is called at the start of the program to fill Play[] with the starting map.
  • [b][red]This message was edited by yrone at 2004-12-15 9:12:28[/red][/b][hr]
    [b][red]This message was edited by yrone at 2004-12-15 9:10:44[/red][/b][hr]
    : :
    : : : You only need to read the file once. Then the map is stored in the RAM memory. If the player enters a word, you insert the entered word into the RAM memory map and redraw that.
    : : : Also you forgot the close the file. This might cause complications for large games.
    : : :
    : : but i need to repeat redraw the map until player enter all the answer
    : : how can i do this.
    : : can you tell me more in detail?!thank you.
    : : o..i see i forgotten to close the file.
    : :
    : In DrawMap() you reload Play[] every time. This means that the addition of the answer is lost, every time DrawMap() is called. The solution is to remove the file-read from that procedure and create a new one LoadMap(), which does nothing but load the map. This procedure is called at the start of the program to fill Play[] with the starting map.
    :
    o..i see i have also made this mistake before
    but the pervious i didn't use file as a drawmap and i had solved it
    but this time is my first time to use file. I cannot able to do this as you mentioned, how can i create a new one. can you show the
    code to me = =" if you are in busy, that's fine
    thank you



  • I have modified my program but it still have problems
    like the following:

    program testing;
    uses wincrt;
    const
    maxrow= 10;
    maxcol= 10;
    type
    puzzle= array[1..maxrow, 1..maxcol] of char;
    var
    play, input: puzzle;
    endgame: boolean;

    procedure OriginalMap(var play: puzzle);
    var
    infile: text;
    row, col, x, y: integer;
    begin
    assign(infile,'d:infile01.txt');
    reset(infile);
    readln(infile, row,col);
    for x:= 1 to row do
    begin
    for y:= 1 to col do
    begin
    read(infile,play[x,y]);
    end;
    end;
    close(infile);
    end;


    procedure DrawMap(var play, input: puzzle);
    var
    infile: text;
    row, col, x, y: integer;
    begin
    for x:= 1 to row do
    begin
    for y:= 1 to col do
    begin
    write(play[x,y]);
    end;
    writeln;
    end;
    end;

    procedure PlayingANY(var play, input: puzzle; var endgame: boolean);
    var
    row, col, x, y: integer;
    ans: char;
    begin
    clrscr;
    OriginalMap(play);
    writeln;
    DrawMap(play, input);
    repeat
    writeln('enter the row');
    readln(row);
    writeln('enter the column');
    readln(col);
    writeln('enter the answer');
    readln(ans);
    play[x,y]:= ans;
    DrawMap(play, input);
    until (endgame= true);
    end;

    begin
    endgame:= false;
    PlayingANY(play, input, endgame);
    end.

    firstly, i creat a new procedure called OriginalMap for store the file data. Secondly, I draw it in the procedure called DrawMap that this procedure for the redraw uses.
    However, the output cannot work:
    output:

    -1"""--
    -"-----
    -"-2--3
    5""""""
    -"-"--"
    -"-"--"
    -"-"--"
    ---"---
    6""""--
    enter the row
    1(row)
    enter the column
    2(col)
    enter the ans
    A(ans)
    {then it runs like this}



    {the map was not shown }




    enter the row

  • : I have modified my program but it still have problems
    : like the following:
    :
    : program testing;
    : uses wincrt;
    : const
    : maxrow= 10;
    : maxcol= 10;
    : type
    : puzzle= array[1..maxrow, 1..maxcol] of char;
    : var
    : play, input: puzzle;
    : endgame: boolean;
    :
    : procedure OriginalMap(var play: puzzle);
    : var
    : infile: text;
    : row, col, x, y: integer;
    : begin
    : assign(infile,'d:infile01.txt');
    : reset(infile);
    : readln(infile, row,col);
    : for x:= 1 to row do
    : begin
    : for y:= 1 to col do
    : begin
    : read(infile,play[x,y]);
    : end;
    : end;
    : close(infile);
    : end;
    :
    :
    : procedure DrawMap(var play, input: puzzle);
    : var
    : infile: text;
    : row, col, x, y: integer;
    : begin
    : for x:= 1 to row do
    : begin
    : for y:= 1 to col do
    : begin
    : write(play[x,y]);
    : end;
    : writeln;
    : end;
    : end;
    :
    : procedure PlayingANY(var play, input: puzzle; var endgame: boolean);
    : var
    : row, col, x, y: integer;
    : ans: char;
    : begin
    : clrscr;
    : OriginalMap(play);
    : writeln;
    : DrawMap(play, input);
    : repeat
    : writeln('enter the row');
    : readln(row);
    : writeln('enter the column');
    : readln(col);
    : writeln('enter the answer');
    : readln(ans);
    : play[x,y]:= ans;
    : DrawMap(play, input);
    : until (endgame= true);
    : end;
    :
    : begin
    : endgame:= false;
    : PlayingANY(play, input, endgame);
    : end.
    :
    : firstly, i creat a new procedure called OriginalMap for store the file data. Secondly, I draw it in the procedure called DrawMap that this procedure for the redraw uses.
    : However, the output cannot work:
    : output:
    :
    : -1"""--
    : -"-----
    : -"-2--3
    : 5""""""
    : -"-"--"
    : -"-"--"
    : -"-"--"
    : ---"---
    : 6""""--
    : enter the row
    : 1(row)
    : enter the column
    : 2(col)
    : enter the ans
    : A(ans)
    : {then it runs like this}
    :
    :
    :
    : {the map was not shown }
    :
    :
    :
    :
    : enter the row
    :
    :
    what's the problem of this = =?!
    plx plx help me
  • : : I have modified my program but it still have problems
    : : like the following:
    : :
    : : program testing;
    : : uses wincrt;
    : : const
    : : maxrow= 10;
    : : maxcol= 10;
    : : type
    : : puzzle= array[1..maxrow, 1..maxcol] of char;
    : : var
    : : play, input: puzzle;
    : : endgame: boolean;
    : :
    : : procedure OriginalMap(var play: puzzle);
    : : var
    : : infile: text;
    : : row, col, x, y: integer;
    : : begin
    : : assign(infile,'d:infile01.txt');
    : : reset(infile);
    : : readln(infile, row,col);
    : : for x:= 1 to row do
    : : begin
    : : for y:= 1 to col do
    : : begin
    : : read(infile,play[x,y]);
    : : end;
    : : end;
    : : close(infile);
    : : end;
    : :
    : :
    : : procedure DrawMap(var play, input: puzzle);
    : : var
    : : infile: text;
    : : row, col, x, y: integer;
    : : begin
    : : for x:= 1 to row do
    : : begin
    : : for y:= 1 to col do
    : : begin
    : : write(play[x,y]);
    : : end;
    : : writeln;
    : : end;
    : : end;
    : :
    : : procedure PlayingANY(var play, input: puzzle; var endgame: boolean);
    : : var
    : : row, col, x, y: integer;
    : : ans: char;
    : : begin
    : : clrscr;
    : : OriginalMap(play);
    : : writeln;
    : : DrawMap(play, input);
    : : repeat
    : : writeln('enter the row');
    : : readln([red]row[/red]);
    : : writeln('enter the column');
    : : readln([red]col[/red]);
    : : writeln('enter the answer');
    : : readln(ans);
    : : play[[red]x,y[/red]]:= ans;
    : : DrawMap(play, input);
    : : until (endgame= true);
    : : end;
    : :
    : : begin
    : : endgame:= false;
    : : PlayingANY(play, input, endgame);
    : : end.
    : :
    : : firstly, i creat a new procedure called OriginalMap for store the file data. Secondly, I draw it in the procedure called DrawMap that this procedure for the redraw uses.
    : : However, the output cannot work:
    : : output:
    : :
    : : -1"""--
    : : -"-----
    : : -"-2--3
    : : 5""""""
    : : -"-"--"
    : : -"-"--"
    : : -"-"--"
    : : ---"---
    : : 6""""--
    : : enter the row
    : : 1(row)
    : : enter the column
    : : 2(col)
    : : enter the ans
    : : A(ans)
    : : {then it runs like this}
    : :
    : :
    : :
    : : {the map was not shown }
    : :
    : :
    : :
    : :
    : : enter the row
    : :
    : :
    : what's the problem of this = =?!
    : plx plx help me
    :
    You have made various mistakes with the X, Y and Row, Col variables. Hint: always use 1 set of variables for indexing an array, either X, Y or Col, Row. Never both. I've highlighted one in the code above but there are also others.
  • [b][red]This message was edited by yrone at 2004-12-15 10:28:33[/red][/b][hr]
    : :
    : You have made various mistakes with the X, Y and Row, Col variables. Hint: always use 1 set of variables for indexing an array, either X, Y or Col, Row. Never both. I've highlighted one in the code above but there are also others.
    :
    o..i see
    i have changed all the x, y into row, col
    but the problem still existed...= =
    the output still like before
    does my procedure PlayingANY make something wrongs>?


  • : [b][red]This message was edited by yrone at 2004-12-15 10:28:33[/red][/b][hr]
    : : :
    : : You have made various mistakes with the X, Y and Row, Col variables. Hint: always use 1 set of variables for indexing an array, either X, Y or Col, Row. Never both. I've highlighted one in the code above but there are also others.
    : :
    : o..i see
    : i have changed all the x, y into row, col
    : but the problem still existed...= =
    : the output still like before
    : does my procedure PlayingANY make something wrongs>?
    :
    :
    :
    The for-do loops are incorrect. They should be running to MaxRow and MaxCol instead of Row and Col.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories