Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
crossword!! Posted by juice88 on 16 Nov 2004 at 3:53 AM
i have some questions about crossword ~
\Please help me!

1) How to set the background colour and text colour in pascal??

2) I want to know does pascal has this function??
if i input the right answer in the game
then the colour of text will change to another colour~~
How can do this??

Suggest the simplest way to me~
THZ~
Report
Re: crossword!! Posted by zibadian on 16 Nov 2004 at 4:12 AM
: i have some questions about crossword ~
: \Please help me!
:
: 1) How to set the background colour and text colour in pascal??
:
: 2) I want to know does pascal has this function??
: if i input the right answer in the game
: then the colour of text will change to another colour~~
: How can do this??
:
: Suggest the simplest way to me~
: THZ~
:
1: TextColor() and TextBackground() in the CRT unit.

2: Set the new textcolor and write the answer again at the same location.
Report
Re: crossword!! Posted by juice88 on 16 Nov 2004 at 4:22 AM
: : i have some questions about crossword ~
: : \Please help me!
: :
: : 1) How to set the background colour and text colour in pascal??
: :
: : 2) I want to know does pascal has this function??
: : if i input the right answer in the game
: : then the colour of text will change to another colour~~
: : How can do this??
: :
: : Suggest the simplest way to me~
: : THZ~
: :
: 1: TextColor() and TextBackground() in the CRT unit.
:
: 2: Set the new textcolor and write the answer again at the same location.
:
THX~
BUT I Have a error200 <division by zero> when i set the text colour.



Report
Re: crossword!! Posted by zibadian on 16 Nov 2004 at 4:40 AM
: : : i have some questions about crossword ~
: : : \Please help me!
: : :
: : : 1) How to set the background colour and text colour in pascal??
: : :
: : : 2) I want to know does pascal has this function??
: : : if i input the right answer in the game
: : : then the colour of text will change to another colour~~
: : : How can do this??
: : :
: : : Suggest the simplest way to me~
: : : THZ~
: : :
: : 1: TextColor() and TextBackground() in the CRT unit.
: :
: : 2: Set the new textcolor and write the answer again at the same location.
: :
: THX~
: BUT I Have a error200 <division by zero> when i set the text colour.
:
:
:
:
If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
Report
Re: crossword!! Posted by juice88 on 19 Nov 2004 at 10:39 AM
: : : : i have some questions about crossword ~
: : : : \Please help me!
: : : :
: : : : 1) How to set the background colour and text colour in pascal??
: : : :
: : : : 2) I want to know does pascal has this function??
: : : : if i input the right answer in the game
: : : : then the colour of text will change to another colour~~
: : : : How can do this??
: : : :
: : : : Suggest the simplest way to me~
: : : : THZ~
: : : :
: : : 1: TextColor() and TextBackground() in the CRT unit.
: : :
: : : 2: Set the new textcolor and write the answer again at the same location.
: : :
: : THX~
: : BUT I Have a error200 <division by zero> when i set the text colour.
: :
: :
: :
: :
: If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
:
OK!The problem has been solved.

2)I think this method is not suitable in my idea.
My idea is like that:
I had set a display with many letters for the player to choose them.
If they choose a right letter, it will change colour.

Any other method??

3)How to set a timer that count down 30 minutes.

Report
Re: crossword!! Posted by zibadian on 19 Nov 2004 at 12:49 PM
This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : i have some questions about crossword ~
: : : : : \Please help me!
: : : : :
: : : : : 1) How to set the background colour and text colour in pascal??
: : : : :
: : : : : 2) I want to know does pascal has this function??
: : : : : if i input the right answer in the game
: : : : : then the colour of text will change to another colour~~
: : : : : How can do this??
: : : : :
: : : : : Suggest the simplest way to me~
: : : : : THZ~
: : : : :
: : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : :
: : : : 2: Set the new textcolor and write the answer again at the same location.
: : : :
: : : THX~
: : : BUT I Have a error200 <division by zero> when i set the text colour.
: : :
: : :
: : :
: : :
: : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: :
: OK!The problem has been solved.
:
: 2)I think this method is not suitable in my idea.
: My idea is like that:
: I had set a display with many letters for the player to choose them.
: If they choose a right letter, it will change colour.
:
: Any other method??
:
: 3)How to set a timer that count down 30 minutes.
:
:
2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.

3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
function TimeInMin: Word;
var
  Hour, Minutes, Seconds, HSeconds: word;
begin
  GetTime(Hour, Minutes, Seconds, HSeconds);
  TimeInMin := Hour*60+Minutes;
end;

var
  GameFinished: boolean;
{ program part }
  GameStartTime := TimeInMin;
  GameFinished := false;

  repeat

    { Do Game }
    { Do not use read() or readln(), because those have their own waiting routine }
    { but readkey() and keypressed() instead }
    { If the player successfully finishes the game set the GameFinished to true }
    { If you want to let the player know how much time is left: }
    { write the following result somewhere: 30-(TimeInMin-GameStart) }

  until (TimeInMin = GameStartTime+30) or GameFinished;

  if GameFinished then
    PlayerHasWon
  else
    PlayerHasLost;



Report
Re: crossword!! Posted by juice88 on 20 Nov 2004 at 6:15 AM
: This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : i have some questions about crossword ~
: : : : : : \Please help me!
: : : : : :
: : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : :
: : : : : : 2) I want to know does pascal has this function??
: : : : : : if i input the right answer in the game
: : : : : : then the colour of text will change to another colour~~
: : : : : : How can do this??
: : : : : :
: : : : : : Suggest the simplest way to me~
: : : : : : THZ~
: : : : : :
: : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : :
: : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : :
: : : : THX~
: : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : :
: : : :
: : : :
: : : :
: : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : :
: : OK!The problem has been solved.
: :
: : 2)I think this method is not suitable in my idea.
: : My idea is like that:
: : I had set a display with many letters for the player to choose them.
: : If they choose a right letter, it will change colour.
: :
: : Any other method??
: :
: : 3)How to set a timer that count down 30 minutes.
: :
: :
: 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
:
: 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
:
: function TimeInMin: Word;
: var
:   Hour, Minutes, Seconds, HSeconds: word;
: begin
:   GetTime(Hour, Minutes, Seconds, HSeconds);
:   TimeInMin := Hour*60+Minutes;
: end;
: 
: var
:   GameFinished: boolean;
: { program part }
:   GameStartTime := TimeInMin;
:   GameFinished := false;
: 
:   repeat
: 
:     { Do Game }
:     { Do not use read() or readln(), because those have their own waiting routine }
:     { but readkey() and keypressed() instead }
:     { If the player successfully finishes the game set the GameFinished to true }
:     { If you want to let the player know how much time is left: }
:     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: 
:   until (TimeInMin = GameStartTime+30) or GameFinished;
: 
:   if GameFinished then
:     PlayerHasWon
:   else
:     PlayerHasLost;
: 

:
:
:
Thank you.
But it said GetTime is a unknown identifier.
what should it set?
uses crt ??uses Doc or something else??
Report
Re: crossword!! Posted by zibadian on 20 Nov 2004 at 6:30 AM
: : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : i have some questions about crossword ~
: : : : : : : \Please help me!
: : : : : : :
: : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : :
: : : : : : : 2) I want to know does pascal has this function??
: : : : : : : if i input the right answer in the game
: : : : : : : then the colour of text will change to another colour~~
: : : : : : : How can do this??
: : : : : : :
: : : : : : : Suggest the simplest way to me~
: : : : : : : THZ~
: : : : : : :
: : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : :
: : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : :
: : : : : THX~
: : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : :
: : : : :
: : : : :
: : : : :
: : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : :
: : : OK!The problem has been solved.
: : :
: : : 2)I think this method is not suitable in my idea.
: : : My idea is like that:
: : : I had set a display with many letters for the player to choose them.
: : : If they choose a right letter, it will change colour.
: : :
: : : Any other method??
: : :
: : : 3)How to set a timer that count down 30 minutes.
: : :
: : :
: : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: :
: : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: :
: : function TimeInMin: Word;
: : var
: :   Hour, Minutes, Seconds, HSeconds: word;
: : begin
: :   GetTime(Hour, Minutes, Seconds, HSeconds);
: :   TimeInMin := Hour*60+Minutes;
: : end;
: : 
: : var
: :   GameFinished: boolean;
: : { program part }
: :   GameStartTime := TimeInMin;
: :   GameFinished := false;
: : 
: :   repeat
: : 
: :     { Do Game }
: :     { Do not use read() or readln(), because those have their own waiting routine }
: :     { but readkey() and keypressed() instead }
: :     { If the player successfully finishes the game set the GameFinished to true }
: :     { If you want to let the player know how much time is left: }
: :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : 
: :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : 
: :   if GameFinished then
: :     PlayerHasWon
: :   else
: :     PlayerHasLost;
: : 

: :
: :
: :
: Thank you.
: But it said GetTime is a unknown identifier.
: what should it set?
: uses crt ??uses Doc or something else??
:
GetTime() is part of the Crt unit. This kind of questions can also be answered by looking the function up in the help files. It lists the unit and also the precise description and declaration.
Report
Re: crossword!! Posted by juice88 on 20 Nov 2004 at 7:16 PM
: : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : i have some questions about crossword ~
: : : : : : : : \Please help me!
: : : : : : : :
: : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : :
: : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : if i input the right answer in the game
: : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : How can do this??
: : : : : : : :
: : : : : : : : Suggest the simplest way to me~
: : : : : : : : THZ~
: : : : : : : :
: : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : :
: : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : :
: : : : : : THX~
: : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : :
: : : : : :
: : : : : :
: : : : : :
: : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : :
: : : : OK!The problem has been solved.
: : : :
: : : : 2)I think this method is not suitable in my idea.
: : : : My idea is like that:
: : : : I had set a display with many letters for the player to choose them.
: : : : If they choose a right letter, it will change colour.
: : : :
: : : : Any other method??
: : : :
: : : : 3)How to set a timer that count down 30 minutes.
: : : :
: : : :
: : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : :
: : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : :
: : : function TimeInMin: Word;
: : : var
: : :   Hour, Minutes, Seconds, HSeconds: word;
: : : begin
: : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : :   TimeInMin := Hour*60+Minutes;
: : : end;
: : : 
: : : var
: : :   GameFinished: boolean;
: : : { program part }
: : :   GameStartTime := TimeInMin;
: : :   GameFinished := false;
: : : 
: : :   repeat
: : : 
: : :     { Do Game }
: : :     { Do not use read() or readln(), because those have their own waiting routine }
: : :     { but readkey() and keypressed() instead }
: : :     { If the player successfully finishes the game set the GameFinished to true }
: : :     { If you want to let the player know how much time is left: }
: : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : 
: : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : 
: : :   if GameFinished then
: : :     PlayerHasWon
: : :   else
: : :     PlayerHasLost;
: : : 

: : :
: : :
: : :
: : Thank you.
: : But it said GetTime is a unknown identifier.
: : what should it set?
: : uses crt ??uses Doc or something else??
: :
: GetTime() is part of the Crt unit. This kind of questions can also be answered by looking the function up in the help files. It lists the unit and also the precise description and declaration.
:
I can't do it .Can you make a sample to me??
Report
Re: crossword!! Posted by zibadian on 21 Nov 2004 at 1:23 AM
: : : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : : i have some questions about crossword ~
: : : : : : : : : \Please help me!
: : : : : : : : :
: : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : :
: : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : if i input the right answer in the game
: : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : How can do this??
: : : : : : : : :
: : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : THZ~
: : : : : : : : :
: : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : :
: : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : :
: : : : : : : THX~
: : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : :
: : : : : OK!The problem has been solved.
: : : : :
: : : : : 2)I think this method is not suitable in my idea.
: : : : : My idea is like that:
: : : : : I had set a display with many letters for the player to choose them.
: : : : : If they choose a right letter, it will change colour.
: : : : :
: : : : : Any other method??
: : : : :
: : : : : 3)How to set a timer that count down 30 minutes.
: : : : :
: : : : :
: : : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : : :
: : : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : : :
: : : : function TimeInMin: Word;
: : : : var
: : : :   Hour, Minutes, Seconds, HSeconds: word;
: : : : begin
: : : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : : :   TimeInMin := Hour*60+Minutes;
: : : : end;
: : : : 
: : : : var
: : : :   GameFinished: boolean;
: : : : { program part }
: : : :   GameStartTime := TimeInMin;
: : : :   GameFinished := false;
: : : : 
: : : :   repeat
: : : : 
: : : :     { Do Game }
: : : :     { Do not use read() or readln(), because those have their own waiting routine }
: : : :     { but readkey() and keypressed() instead }
: : : :     { If the player successfully finishes the game set the GameFinished to true }
: : : :     { If you want to let the player know how much time is left: }
: : : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : : 
: : : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : : 
: : : :   if GameFinished then
: : : :     PlayerHasWon
: : : :   else
: : : :     PlayerHasLost;
: : : : 

: : : :
: : : :
: : : :
: : : Thank you.
: : : But it said GetTime is a unknown identifier.
: : : what should it set?
: : : uses crt ??uses Doc or something else??
: : :
: : GetTime() is part of the Crt unit. This kind of questions can also be answered by looking the function up in the help files. It lists the unit and also the precise description and declaration.
: :
: I can't do it .Can you make a sample to me??
:
Here is a sample, which asks you to type a word in 3 minutes:
uses Crt;

function TimeInMin: Word;
var
  Hour, Minutes, Seconds, HSeconds: word;
begin
  GetTime(Hour, Minutes, Seconds, HSeconds);
  TimeInMin := Hour*60+Minutes;
end;

var
  GameFinished: boolean;
  TypedWord: string;
  ch: char;
begin
  GameStartTime := TimeInMin;
  GameFinished := false;
  TypedWord := '';
  GotoXY(1,1); write('Enter word: ');
  repeat
    if Keypressed then
    begin
      ch := readkey;
      case ch of
        #8 {Backspace}: Delete(TypedWord, Length(TypedWord), 1);
        #13 {Enter}: GameFinished := true; {end game}
        #0 {Extended char}: ch := readkey; {clear buffer}
        #1..#7,#9..#12,#14..#19 {system commands}: begin end; {ignore}
        else TypedWord := TypedWord + ch;
      end;
      GotoXY(1,1); write('Enter word: ', TypedWord);
    end;
  until (TimeInMin = GameStartTime+3) or GameFinished;

  if GameFinished then 
  begin
    if TypedWord = 'This is an example game' then
      writeln('You typed the correct word.')
    else
      writeln('You typed an incorrect word.')
  end else
    writeln('You did not type fast enough');
  readln;
end.

Report
Re: crossword!! Posted by juice88 on 21 Nov 2004 at 3:01 AM
: : : : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : : : i have some questions about crossword ~
: : : : : : : : : : \Please help me!
: : : : : : : : : :
: : : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : : :
: : : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : : if i input the right answer in the game
: : : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : : How can do this??
: : : : : : : : : :
: : : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : : THZ~
: : : : : : : : : :
: : : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : : :
: : : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : : :
: : : : : : : : THX~
: : : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : : :
: : : : : : OK!The problem has been solved.
: : : : : :
: : : : : : 2)I think this method is not suitable in my idea.
: : : : : : My idea is like that:
: : : : : : I had set a display with many letters for the player to choose them.
: : : : : : If they choose a right letter, it will change colour.
: : : : : :
: : : : : : Any other method??
: : : : : :
: : : : : : 3)How to set a timer that count down 30 minutes.
: : : : : :
: : : : : :
: : : : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : : : :
: : : : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : : : :
: : : : : function TimeInMin: Word;
: : : : : var
: : : : :   Hour, Minutes, Seconds, HSeconds: word;
: : : : : begin
: : : : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : : : :   TimeInMin := Hour*60+Minutes;
: : : : : end;
: : : : : 
: : : : : var
: : : : :   GameFinished: boolean;
: : : : : { program part }
: : : : :   GameStartTime := TimeInMin;
: : : : :   GameFinished := false;
: : : : : 
: : : : :   repeat
: : : : : 
: : : : :     { Do Game }
: : : : :     { Do not use read() or readln(), because those have their own waiting routine }
: : : : :     { but readkey() and keypressed() instead }
: : : : :     { If the player successfully finishes the game set the GameFinished to true }
: : : : :     { If you want to let the player know how much time is left: }
: : : : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : : : 
: : : : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : : : 
: : : : :   if GameFinished then
: : : : :     PlayerHasWon
: : : : :   else
: : : : :     PlayerHasLost;
: : : : : 

: : : : :
: : : : :
: : : : :
: : : : Thank you.
: : : : But it said GetTime is a unknown identifier.
: : : : what should it set?
: : : : uses crt ??uses Doc or something else??
: : : :
: : : GetTime() is part of the Crt unit. This kind of questions can also be answered by looking the function up in the help files. It lists the unit and also the precise description and declaration.
: : :
: : I can't do it .Can you make a sample to me??
: :
: Here is a sample, which asks you to type a word in 3 minutes:
:
: uses Crt;
: 
: function TimeInMin: Word;
: var
:   Hour, Minutes, Seconds, HSeconds: word;
: begin
:   GetTime(Hour, Minutes, Seconds, HSeconds);
:   TimeInMin := Hour*60+Minutes;
: end;
: 
: var
:   GameFinished: boolean;
:   TypedWord: string;
:   ch: char;
: begin
:   GameStartTime := TimeInMin;
:   GameFinished := false;
:   TypedWord := '';
:   GotoXY(1,1); write('Enter word: ');
:   repeat
:     if Keypressed then
:     begin
:       ch := readkey;
:       case ch of
:         #8 {Backspace}: Delete(TypedWord, Length(TypedWord), 1);
:         #13 {Enter}: GameFinished := true; {end game}
:         #0 {Extended char}: ch := readkey; {clear buffer}
:         #1..#7,#9..#12,#14..#19 {system commands}: begin end; {ignore}
:         else TypedWord := TypedWord + ch;
:       end;
:       GotoXY(1,1); write('Enter word: ', TypedWord);
:     end;
:   until (TimeInMin = GameStartTime+3) or GameFinished;
: 
:   if GameFinished then 
:   begin
:     if TypedWord = 'This is an example game' then
:       writeln('You typed the correct word.')
:     else
:       writeln('You typed an incorrect word.')
:   end else
:     writeln('You did not type fast enough');
:   readln;
: end.
: 

:
THX!!!!
{ If you want to let the player know how much time is left: }
{ write the following result somewhere: 30-(TimeInMin-GameStart) }
How about this??

Report
Re: crossword!! Posted by zibadian on 21 Nov 2004 at 4:08 AM
: This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : i have some questions about crossword ~
: : : : : : \Please help me!
: : : : : :
: : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : :
: : : : : : 2) I want to know does pascal has this function??
: : : : : : if i input the right answer in the game
: : : : : : then the colour of text will change to another colour~~
: : : : : : How can do this??
: : : : : :
: : : : : : Suggest the simplest way to me~
: : : : : : THZ~
: : : : : :
: : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : :
: : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : :
: : : : THX~
: : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : :
: : : :
: : : :
: : : :
: : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : :
: : OK!The problem has been solved.
: :
: : 2)I think this method is not suitable in my idea.
: : My idea is like that:
: : I had set a display with many letters for the player to choose them.
: : If they choose a right letter, it will change colour.
: :
: : Any other method??
: :
: : 3)How to set a timer that count down 30 minutes.
: :
: :
: 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
:
: 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
:
: function TimeInMin: Word;
: var
:   Hour, Minutes, Seconds, HSeconds: word;
: begin
:   GetTime(Hour, Minutes, Seconds, HSeconds);
:   TimeInMin := Hour*60+Minutes;
: end;
: 
: var
:   GameFinished: boolean;
: { program part }
:   GameStartTime := TimeInMin;
:   GameFinished := false;
: 
:   repeat
: 
:     { Do Game }
:     { Do not use read() or readln(), because those have their own waiting routine }
:     { but readkey() and keypressed() instead }
:     { If the player successfully finishes the game set the GameFinished to true }
:     { If you want to let the player know how much time is left: }
:     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: 
:   until (TimeInMin = GameStartTime+30) or GameFinished;
: 
:   if GameFinished then
:     PlayerHasWon
:   else
:     PlayerHasLost;
: 

:
:
:
That can be inserted any where in the loop:
  GotoXY(1,2);
  write('Time left: ', 3-(TimeInMin-GameStart));

This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
Report
Re: crossword!! Posted by juice88 on 26 Nov 2004 at 9:35 PM
: : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : i have some questions about crossword ~
: : : : : : : \Please help me!
: : : : : : :
: : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : :
: : : : : : : 2) I want to know does pascal has this function??
: : : : : : : if i input the right answer in the game
: : : : : : : then the colour of text will change to another colour~~
: : : : : : : How can do this??
: : : : : : :
: : : : : : : Suggest the simplest way to me~
: : : : : : : THZ~
: : : : : : :
: : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : :
: : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : :
: : : : : THX~
: : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : :
: : : : :
: : : : :
: : : : :
: : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : :
: : : OK!The problem has been solved.
: : :
: : : 2)I think this method is not suitable in my idea.
: : : My idea is like that:
: : : I had set a display with many letters for the player to choose them.
: : : If they choose a right letter, it will change colour.
: : :
: : : Any other method??
: : :
: : : 3)How to set a timer that count down 30 minutes.
: : :
: : :
: : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: :
: : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: :
: : function TimeInMin: Word;
: : var
: :   Hour, Minutes, Seconds, HSeconds: word;
: : begin
: :   GetTime(Hour, Minutes, Seconds, HSeconds);
: :   TimeInMin := Hour*60+Minutes;
: : end;
: : 
: : var
: :   GameFinished: boolean;
: : { program part }
: :   GameStartTime := TimeInMin;
: :   GameFinished := false;
: : 
: :   repeat
: : 
: :     { Do Game }
: :     { Do not use read() or readln(), because those have their own waiting routine }
: :     { but readkey() and keypressed() instead }
: :     { If the player successfully finishes the game set the GameFinished to true }
: :     { If you want to let the player know how much time is left: }
: :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : 
: :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : 
: :   if GameFinished then
: :     PlayerHasWon
: :   else
: :     PlayerHasLost;
: : 

: :
: :
: :
: That can be inserted any where in the loop:
:
:   GotoXY(1,2);
:   write('Time left: ', 3-(TimeInMin-GameStart));
: 

: This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
:
I can't play the timer and main program at the same time ~
Maybe some program formed
Can you help me to see~?
My program:
repeat
GotoXY(1,2);
write('Time left: ', 3-(TimeInMin-GameStart));

repeat
ans 1
until XXXXX

repeat
ans 2
until XXXXX

repeat
ans 3
until XXX

until
(TimeInMin = GameStartTime+3) or GameFinished;
write('You are loss);

it can't work~


Report
Re: crossword!! Posted by zibadian on 27 Nov 2004 at 10:46 AM
: : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : i have some questions about crossword ~
: : : : : : : : \Please help me!
: : : : : : : :
: : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : :
: : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : if i input the right answer in the game
: : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : How can do this??
: : : : : : : :
: : : : : : : : Suggest the simplest way to me~
: : : : : : : : THZ~
: : : : : : : :
: : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : :
: : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : :
: : : : : : THX~
: : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : :
: : : : : :
: : : : : :
: : : : : :
: : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : :
: : : : OK!The problem has been solved.
: : : :
: : : : 2)I think this method is not suitable in my idea.
: : : : My idea is like that:
: : : : I had set a display with many letters for the player to choose them.
: : : : If they choose a right letter, it will change colour.
: : : :
: : : : Any other method??
: : : :
: : : : 3)How to set a timer that count down 30 minutes.
: : : :
: : : :
: : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : :
: : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : :
: : : function TimeInMin: Word;
: : : var
: : :   Hour, Minutes, Seconds, HSeconds: word;
: : : begin
: : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : :   TimeInMin := Hour*60+Minutes;
: : : end;
: : : 
: : : var
: : :   GameFinished: boolean;
: : : { program part }
: : :   GameStartTime := TimeInMin;
: : :   GameFinished := false;
: : : 
: : :   repeat
: : : 
: : :     { Do Game }
: : :     { Do not use read() or readln(), because those have their own waiting routine }
: : :     { but readkey() and keypressed() instead }
: : :     { If the player successfully finishes the game set the GameFinished to true }
: : :     { If you want to let the player know how much time is left: }
: : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : 
: : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : 
: : :   if GameFinished then
: : :     PlayerHasWon
: : :   else
: : :     PlayerHasLost;
: : : 

: : :
: : :
: : :
: : That can be inserted any where in the loop:
: :
: :   GotoXY(1,2);
: :   write('Time left: ', 3-(TimeInMin-GameStart));
: : 

: : This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
: :
: I can't play the timer and main program at the same time ~
: Maybe some program formed
: Can you help me to see~?
: My program:
: repeat
: GotoXY(1,2);
: write('Time left: ', 3-(TimeInMin-GameStart));
:
: repeat
: ans 1
: until XXXXX
:
: repeat
: ans 2
: until XXXXX
:
: repeat
: ans 3
: until XXX
:
: until
: (TimeInMin = GameStartTime+3) or GameFinished;
: write('You are loss);
:
: it can't work~
:
:
:
There is only 1 repeat-until loop:
  repeat
    GotoXY(1,2);
    write('Time left: ', 3-(TimeInMin-GameStart));
    ans 1 
    ans 2
    ans 3
  until 
    (TimeInMin = GameStartTime+3) or GameFinished;
  write('You are loss);

If you want to indicate a wrong answer, you need to add a boolean variable to the game. This variable can also be used to finish the loop.
Report
Re: crossword!! Posted by juice88 on 22 Dec 2004 at 8:37 AM
This message was edited by juice88 at 2004-12-22 8:37:46

: : : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : : i have some questions about crossword ~
: : : : : : : : : \Please help me!
: : : : : : : : :
: : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : :
: : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : if i input the right answer in the game
: : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : How can do this??
: : : : : : : : :
: : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : THZ~
: : : : : : : : :
: : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : :
: : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : :
: : : : : : : THX~
: : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : :
: : : : : OK!The problem has been solved.
: : : : :
: : : : : 2)I think this method is not suitable in my idea.
: : : : : My idea is like that:
: : : : : I had set a display with many letters for the player to choose them.
: : : : : If they choose a right letter, it will change colour.
: : : : :
: : : : : Any other method??
: : : : :
: : : : : 3)How to set a timer that count down 30 minutes.
: : : : :
: : : : :
: : : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : : :
: : : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : : :
: : : : function TimeInMin: Word;
: : : : var
: : : :   Hour, Minutes, Seconds, HSeconds: word;
: : : : begin
: : : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : : :   TimeInMin := Hour*60+Minutes;
: : : : end;
: : : : 
: : : : var
: : : :   GameFinished: boolean;
: : : : { program part }
: : : :   GameStartTime := TimeInMin;
: : : :   GameFinished := false;
: : : : 
: : : :   repeat
: : : : 
: : : :     { Do Game }
: : : :     { Do not use read() or readln(), because those have their own waiting routine }
: : : :     { but readkey() and keypressed() instead }
: : : :     { If the player successfully finishes the game set the GameFinished to true }
: : : :     { If you want to let the player know how much time is left: }
: : : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : : 
: : : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : : 
: : : :   if GameFinished then
: : : :     PlayerHasWon
: : : :   else
: : : :     PlayerHasLost;
: : : : 

: : : :
: : : :
: : : :
: : : That can be inserted any where in the loop:
: : :
: : :   GotoXY(1,2);
: : :   write('Time left: ', 3-(TimeInMin-GameStart));
: : : 

: : : This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
: : :
: : I can't play the timer and main program at the same time ~
: : Maybe some program formed
: : Can you help me to see~?
: : My program:
: : repeat
: : GotoXY(1,2);
: : write('Time left: ', 3-(TimeInMin-GameStart));
: :
: : repeat
: : ans 1
: : until XXXXX
: :
: : repeat
: : ans 2
: : until XXXXX
: :
: : repeat
: : ans 3
: : until XXX
: :
: : until
: : (TimeInMin = GameStartTime+3) or GameFinished;
: : write('You are loss);
: :
: : it can't work~
: :
: :
: :
: There is only 1 repeat-until loop:
:
:   repeat
:     GotoXY(1,2);
:     write('Time left: ', 3-(TimeInMin-GameStart));
:     ans 1 
:     ans 2
:     ans 3
:   until 
:     (TimeInMin = GameStartTime+3) or GameFinished;
:   write('You are loss);
: 

: If you want to indicate a wrong answer, you need to add a boolean variable to the game. This variable can also be used to finish the loop.
:
I stil cant do this!!
><"
I think you misunderstand my program~
My program is check the letter of the answer one by one ,
not check the complete answer one by one.
By similiar
if the answer is 'Food'
The player first input the first letter of his answer
then I check it .
if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
Therefore ,many repeat loop must be used , then how can I add the timer in it??

Sorry, my expreesion is not clear,
hope that you can solve my program.


Report
Re: crossword!! Posted by zibadian on 22 Dec 2004 at 9:38 AM
: This message was edited by juice88 at 2004-12-22 8:37:46

: : : : : This message was edited by zibadian at 2004-11-19 12:49:51

: : : : : : : : : : i have some questions about crossword ~
: : : : : : : : : : \Please help me!
: : : : : : : : : :
: : : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : : :
: : : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : : if i input the right answer in the game
: : : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : : How can do this??
: : : : : : : : : :
: : : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : : THZ~
: : : : : : : : : :
: : : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : : :
: : : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : : :
: : : : : : : : THX~
: : : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : : :
: : : : : : OK!The problem has been solved.
: : : : : :
: : : : : : 2)I think this method is not suitable in my idea.
: : : : : : My idea is like that:
: : : : : : I had set a display with many letters for the player to choose them.
: : : : : : If they choose a right letter, it will change colour.
: : : : : :
: : : : : : Any other method??
: : : : : :
: : : : : : 3)How to set a timer that count down 30 minutes.
: : : : : :
: : : : : :
: : : : : 2: You could change the color directly in the video memory, but that would require some assembly and an intricate knowledge of the video memory. The only true-Pascal way is to use TextColor(), TextBackround(), GotoXY() and write() to set it.
: : : : :
: : : : : 3: The only two ways to do this is to either use interrupts, or use a loop and GetTime(). Here is a sample code to illustrate the latter:
: : : : :
: : : : : function TimeInMin: Word;
: : : : : var
: : : : :   Hour, Minutes, Seconds, HSeconds: word;
: : : : : begin
: : : : :   GetTime(Hour, Minutes, Seconds, HSeconds);
: : : : :   TimeInMin := Hour*60+Minutes;
: : : : : end;
: : : : : 
: : : : : var
: : : : :   GameFinished: boolean;
: : : : : { program part }
: : : : :   GameStartTime := TimeInMin;
: : : : :   GameFinished := false;
: : : : : 
: : : : :   repeat
: : : : : 
: : : : :     { Do Game }
: : : : :     { Do not use read() or readln(), because those have their own waiting routine }
: : : : :     { but readkey() and keypressed() instead }
: : : : :     { If the player successfully finishes the game set the GameFinished to true }
: : : : :     { If you want to let the player know how much time is left: }
: : : : :     { write the following result somewhere: 30-(TimeInMin-GameStart) }
: : : : : 
: : : : :   until (TimeInMin = GameStartTime+30) or GameFinished;
: : : : : 
: : : : :   if GameFinished then
: : : : :     PlayerHasWon
: : : : :   else
: : : : :     PlayerHasLost;
: : : : : 

: : : : :
: : : : :
: : : : :
: : : : That can be inserted any where in the loop:
: : : :
: : : :   GotoXY(1,2);
: : : :   write('Time left: ', 3-(TimeInMin-GameStart));
: : : : 

: : : : This code will cause flickering of the time left. A better way is to check if the time left is changed since the last writing of it, which involves a simple if-then and storing the value of time left after writing it.
: : : :
: : : I can't play the timer and main program at the same time ~
: : : Maybe some program formed
: : : Can you help me to see~?
: : : My program:
: : : repeat
: : : GotoXY(1,2);
: : : write('Time left: ', 3-(TimeInMin-GameStart));
: : :
: : : repeat
: : : ans 1
: : : until XXXXX
: : :
: : : repeat
: : : ans 2
: : : until XXXXX
: : :
: : : repeat
: : : ans 3
: : : until XXX
: : :
: : : until
: : : (TimeInMin = GameStartTime+3) or GameFinished;
: : : write('You are loss);
: : :
: : : it can't work~
: : :
: : :
: : :
: : There is only 1 repeat-until loop:
: :
: :   repeat
: :     GotoXY(1,2);
: :     write('Time left: ', 3-(TimeInMin-GameStart));
: :     ans 1 
: :     ans 2
: :     ans 3
: :   until 
: :     (TimeInMin = GameStartTime+3) or GameFinished;
: :   write('You are loss);
: : 

: : If you want to indicate a wrong answer, you need to add a boolean variable to the game. This variable can also be used to finish the loop.
: :
: I stil cant do this!!
: ><"
: I think you misunderstand my program~
: My program is check the letter of the answer one by one ,
: not check the complete answer one by one.
: By similiar
: if the answer is 'Food'
: The player first input the first letter of his answer
: then I check it .
: if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
: Therefore ,many repeat loop must be used , then how can I add the timer in it??
:
: Sorry, my expreesion is not clear,
: hope that you can solve my program.
:
:
:
The following code lets the user enter 1 letter at a time. This is repeated for the entire answer or the time runs out. I've left out some simple parts, or parts, which I already detailed previously.
  for i := 1 to Length(Answer) do
  begin
    repeat
      { User enters letter }
    until (UserEnteredLetter = Answer[i]) or (TimeInMin => GameStartTime+3);
    if TimeInMin => GameStartTime+3 then
      Break;
  end;

Report
Re: crossword!! Posted by juice88 on 25 Dec 2004 at 9:22 AM
: : :
: : I stil cant do this!!
: : ><"
: : I think you misunderstand my program~
: : My program is check the letter of the answer one by one ,
: : not check the complete answer one by one.
: : By similiar
: : if the answer is 'Food'
: : The player first input the first letter of his answer
: : then I check it .
: : if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
: : Therefore ,many repeat loop must be used , then how can I add the timer in it??
: :
: : Sorry, my expreesion is not clear,
: : hope that you can solve my program.
: :
: :
: :
: The following code lets the user enter 1 letter at a time. This is repeated for the entire answer or the time runs out. I've left out some simple parts, or parts, which I already detailed previously.
:
:   for i := 1 to Length(Answer) do
:   begin
:     repeat
:       { User enters letter }
:     until (UserEnteredLetter = Answer[i]) or (TimeInMin => GameStartTime+3);
:     if TimeInMin => GameStartTime+3 then
:       Break;
:   end;
: 

:

thank you!!
Can you help me to find out what mistakes are??
begin
Answer:='Food';
for i:=1 to Length(Answer) do
begin
repeat
if Keypressed then
begin
GotoXY(8,34);
write(3-(TimeInMin-GameStartTime));
GotoXY(3,21);
ch :=readkey;
case ch of
#8 :Delete(PlayerGuess,Length(PlayerGuess),1);
#13 :InputFinished :=true;
#0 : ch:=readkey;
#1..#7,#9..#12,#14..#19:begin end;
else PlayerGuess:=PlayerGuess+ch;
end;
if i=1 then                  { Go to the certain position then enter 
GotoXY(3,21);                   letter}
write(ch);

if i=2 then
GotoXY(5,21);
write(ch);

if i=3 then
GotoXY(8,21);
write(ch);

if i=4 then
GotoXY(11,21);
write(ch);
end;
until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;

if InputFinshed then
begin

if PlayerGuess[1]=Answer[1]   <--{ change colour in display }
then
GotoXY(1,2)
TextColor(7);
write('F');

if PlayerGuess[2]=Answer[2]
then
GotoXY(1,5);
TextColor(7);
write('O');

if PlayerGuess[3]=Answer[3]
then
GotoXY(3,5);
TextColor(7);
write('O');

if PlayerGuess[4]=Answer[4]
then
GotoXY(3,6);
TextColor(7);
write('D');

if PlayerGuess[i]=Answer[i]
then
write('Win');

if PlayerGuess[i] <> Answer[i]  <---{ Get hint }
then 
Hint

if Hint=4  <---{ no chance}
then
write('Loss');

if TimeInMin = GameStartTime+3  {Times up}
then
write'Times up');

end.


The problem is the position of the user entered.
I have creat certain boxes that the user can fill in the box.
But how to set the coordinate in readkey ??



:
Report
Re: crossword!! Posted by juice88 on 27 Dec 2004 at 11:36 PM
This message was edited by juice88 at 2004-12-31 23:54:41

: : : :
: : : I stil cant do this!!
: : : ><"
: : : I think you misunderstand my program~
: : : My program is check the letter of the answer one by one ,
: : : not check the complete answer one by one.
: : : By similiar
: : : if the answer is 'Food'
: : : The player first input the first letter of his answer
: : : then I check it .
: : : if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
: : : Therefore ,many repeat loop must be used , then how can I add the timer in it??
: : :
: : : Sorry, my expreesion is not clear,
: : : hope that you can solve my program.
: : :
: : :
: : :
: : The following code lets the user enter 1 letter at a time. This is repeated for the entire answer or the time runs out. I've left out some simple parts, or parts, which I already detailed previously.
: :
: :   for i := 1 to Length(Answer) do
: :   begin
: :     repeat
: :       { User enters letter }
: :     until (UserEnteredLetter = Answer[i]) or (TimeInMin => GameStartTime+3);
: :     if TimeInMin => GameStartTime+3 then
: :       Break;
: :   end;
: : 

: :
:
: thank you!!
: Can you help me to find out what mistakes are??
:
: begin
: Answer:='Food';
: for i:=1 to Length(Answer) do
: begin
: repeat
: if Keypressed then
: begin
: GotoXY(8,34);
: write(3-(TimeInMin-GameStartTime));
: GotoXY(3,21);
: ch :=readkey;
: case ch of
: #8 :Delete(PlayerGuess,Length(PlayerGuess),1);
: #13 :InputFinished :=true;
: #0 : ch:=readkey;
: #1..#7,#9..#12,#14..#19:begin end;
: else PlayerGuess:=PlayerGuess+ch;
: end;
: if i=1 then                  { Go to the certain position then enter 
: GotoXY(3,21);                   letter}
: write(ch);
: 
: if i=2 then
: GotoXY(5,21);
: write(ch);
: 
: if i=3 then
: GotoXY(8,21);
: write(ch);
: 
: if i=4 then
: GotoXY(11,21);
: write(ch);
: end;
: until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;
: 
: if InputFinshed then
: begin
: 
: if PlayerGuess[1]=Answer[1]   <--{ change colour in display }
: then
: GotoXY(1,2)
: TextColor(7);
: write('F');
: 
: if PlayerGuess[2]=Answer[2]
: then
: GotoXY(1,5);
: TextColor(7);
: write('O');
: 
: if PlayerGuess[3]=Answer[3]
: then
: GotoXY(3,5);
: TextColor(7);
: write('O');
: 
: if PlayerGuess[4]=Answer[4]
: then
: GotoXY(3,6);
: TextColor(7);
: write('D');
: 
: if PlayerGuess[i]=Answer[i]
: then
: write('Win');
: 
: if PlayerGuess[i] <> Answer[i]  <---{ Get hint }
: then 
: Hint
: 
: if Hint=4  <---{ no chance}
: then
: write('Loss');
: 
: if TimeInMin = GameStartTime+3  {Times up}
: then
: write'Times up');
: 
: end.
: 

:
: The problem is the position of the user entered.
: I have creat certain boxes that the user can fill in the box.
: But how to set the coordinate in readkey ??
:
:
:
: :
:
Zibadian???
Are you here??



Report
Re: crossword!! Posted by juice88 on 31 Dec 2004 at 11:57 PM
: : : :
: : : I stil cant do this!!
: : : ><"
: : : I think you misunderstand my program~
: : : My program is check the letter of the answer one by one ,
: : : not check the complete answer one by one.
: : : By similiar
: : : if the answer is 'Food'
: : : The player first input the first letter of his answer
: : : then I check it .
: : : if his lettter is incorrect , he will input it again until the letter is 'F' ,then he can input the second letter.
: : : Therefore ,many repeat loop must be used , then how can I add the timer in it??
: : :
: : : Sorry, my expreesion is not clear,
: : : hope that you can solve my program.
: : :
: : :
: : :
: : The following code lets the user enter 1 letter at a time. This is repeated for the entire answer or the time runs out. I've left out some simple parts, or parts, which I already detailed previously.
: :
: :   for i := 1 to Length(Answer) do
: :   begin
: :     repeat
: :       { User enters letter }
: :     until (UserEnteredLetter = Answer[i]) or (TimeInMin => GameStartTime+3);
: :     if TimeInMin => GameStartTime+3 then
: :       Break;
: :   end;
: : 

: :
:
: thank you!!
: Can you help me to find out what mistakes are??
:
: begin
: Answer:='Food';
: for i:=1 to Length(Answer) do
: begin
: repeat
: if Keypressed then
: begin
: GotoXY(8,34);
: write(3-(TimeInMin-GameStartTime));
: GotoXY(3,21);
: ch :=readkey;
: case ch of
: #8 :Delete(PlayerGuess,Length(PlayerGuess),1);
: #13 :InputFinished :=true;
: #0 : ch:=readkey;
: #1..#7,#9..#12,#14..#19:begin end;
: else PlayerGuess:=PlayerGuess+ch;
: end;
: if i=1 then                  { Go to the certain position then enter 
: GotoXY(3,21);                   letter}
: write(ch);
: 
: if i=2 then
: GotoXY(5,21);
: write(ch);
: 
: if i=3 then
: GotoXY(8,21);
: write(ch);
: 
: if i=4 then
: GotoXY(11,21);
: write(ch);
: end;
: until (PlayerGuess[i]=Answer[i]) or (TimeInMin >= GameStartTime+3) ;
: 
: if InputFinshed then
: begin
: 
: if PlayerGuess[1]=Answer[1]   <--{ change colour in display }
: then
: GotoXY(1,2)
: TextColor(7);
: write('F');
: 
: if PlayerGuess[2]=Answer[2]
: then
: GotoXY(1,5);
: TextColor(7);
: write('O');
: 
: if PlayerGuess[3]=Answer[3]
: then
: GotoXY(3,5);
: TextColor(7);
: write('O');
: 
: if PlayerGuess[4]=Answer[4]
: then
: GotoXY(3,6);
: TextColor(7);
: write('D');
: 
: if PlayerGuess[i]=Answer[i]
: then
: write('Win');
: 
: if PlayerGuess[i] <> Answer[i]  <---{ Get hint }
: then 
: Hint
: 
: if Hint=4  <---{ no chance}
: then
: write('Loss');
: 
: if TimeInMin = GameStartTime+3  {Times up}
: then
: write'Times up');
: 
: end.
: 

:
: The problem is the position of the user entered.
: I have creat certain boxes that the user can fill in the box.
: But how to set the coordinate in readkey ??
:
:
:
: :
:
It is very annoying~
Report
Re: crossword!! Posted by john222 on 24 Nov 2004 at 1:49 AM
I don't know how to do it, but can you me the program . I'd like to
play it
Report
Re: crossword!! Posted by zibadian on 1 Jan 2005 at 4:17 AM
: : : : : i have some questions about crossword ~
: : : : : \Please help me!
: : : : :
: : : : : 1) How to set the background colour and text colour in pascal??
: : : : :
: : : : : 2) I want to know does pascal has this function??
: : : : : if i input the right answer in the game
: : : : : then the colour of text will change to another colour~~
: : : : : How can do this??
: : : : :
: : : : : Suggest the simplest way to me~
: : : : : THZ~
: : : : :
: : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : :
: : : : 2: Set the new textcolor and write the answer again at the same location.
: : : :
: : : THX~
: : : BUT I Have a error200 <division by zero> when i set the text colour.
: : :
: : :
: : :
: : :
: : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: :
: OK!The problem has been solved.
:
: 2)I think this method is not suitable in my idea.
: My idea is like that:
: I had set a display with many letters for the player to choose them.
: If they choose a right letter, it will change colour.
:
: Any other method??
:
: 3)How to set a timer that count down 30 minutes.
:
:
Here is a little function I write for you to handle the key presses:
function ReadText(var UserInput: string; const X, Y: integer): boolean;
{ This is a non-blocking user entry function
  Handles the following key-strokes:
  - Backspace: removes last character
  - Enter: Sets the result to true
  - ASCII Code 32 (space) and upwards are valid characters
  - Removes extended (multi-byte) keypresses
  Other features:
  - Reduces flickering by first checking if the user actually pressed a key
  - positions the input field at X, Y relative to top-left of the screen
}
begin
  ReadText := false; { Assume a non-enter key }
  if KeyPressed then { Check for key-press }
  begin
    ch := ReadKey; { Get the ASCII key code }
    case ch of
      #0..#7: ;
      #8: Delete(UserInput, Length(UserInput), 1);
      #9..#12: ;
      #13: ReadText := true;
      #14..#31: ;
      else UserInput := UserInput + ch;
    end;
    while KeyPressed do ReadKey; { Remove extended }
    GotoXY(X, Y); { Show the result at X, Y }
    write(UserInput);
  end;
end;

It is untested, but should work.
Report
Re: crossword!! Posted by juice88 on 4 Jan 2005 at 6:35 AM
: : : : : : i have some questions about crossword ~
: : : : : : \Please help me!
: : : : : :
: : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : :
: : : : : : 2) I want to know does pascal has this function??
: : : : : : if i input the right answer in the game
: : : : : : then the colour of text will change to another colour~~
: : : : : : How can do this??
: : : : : :
: : : : : : Suggest the simplest way to me~
: : : : : : THZ~
: : : : : :
: : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : :
: : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : :
: : : : THX~
: : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : :
: : : :
: : : :
: : : :
: : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : :
: : OK!The problem has been solved.
: :
: : 2)I think this method is not suitable in my idea.
: : My idea is like that:
: : I had set a display with many letters for the player to choose them.
: : If they choose a right letter, it will change colour.
: :
: : Any other method??
: :
: : 3)How to set a timer that count down 30 minutes.
: :
: :
: Here is a little function I write for you to handle the key presses:
:
: function ReadText(var UserInput: string; const X, Y: integer): boolean;
: { This is a non-blocking user entry function
:   Handles the following key-strokes:
:   - Backspace: removes last character
:   - Enter: Sets the result to true
:   - ASCII Code 32 (space) and upwards are valid characters
:   - Removes extended (multi-byte) keypresses
:   Other features:
:   - Reduces flickering by first checking if the user actually pressed a key
:   - positions the input field at X, Y relative to top-left of the screen
: }
: begin
:   ReadText := false; { Assume a non-enter key }
:   if KeyPressed then { Check for key-press }
:   begin
:     ch := ReadKey; { Get the ASCII key code }
:     case ch of
:       #0..#7: ;
:       #8: Delete(UserInput, Length(UserInput), 1);
:       #9..#12: ;
:       #13: ReadText := true;
:       #14..#31: ;
:       else UserInput := UserInput + ch;
:     end;
:     while KeyPressed do ReadKey; { Remove extended }
:     GotoXY(X, Y); { Show the result at X, Y }
:     write(UserInput);
:   end;
: end;
: 

: It is untested, but should work.
:
I have followed your function but why it can't work ??
function ReadText(var UserInput: string; const X, Y: integer): boolean;
begin
  ReadText := false; { Assume a non-enter key }
  if KeyPressed then { Check for key-press }
  begin
    GotoXY(X,Y);
    ch := ReadKey; { Get the ASCII key code }
    case ch of
      #0..#7: ;
      #8: Delete(UserInput, Length(UserInput), 1);
      #9 :write('Answer is CLOCK TOWER. (Press ESC to exit)');
      #10..#12: ;
      #13: ReadText := true;
      #14..#26: ;
      #27 :exit; [press ESC then exit]
      #28..#31: ;
      else UserInput := UserInput + ch;
    end;
    while KeyPressed do ReadKey; { Remove extended }
    GotoXY(X, Y); { Show the result at X, Y }
    write(UserInput);
  end;
end;

begin
ClrScr;
Display;
GameStartTime := TimeInMin;
Answer:='LOCKTOWE';
UserInput:= '';


for i:=1 to Length(Answer) do
begin
repeat
GotoXY(8,34);
write(3-(TimeInMin-GameStartTime));

if i=1 then
ReadText(UserInput,12,21);

if i=2 then
ReadText(UserInput,18,21);

if i=3 then
ReadText(UserInput,24,21);

if i=4 then
ReadText(UserInput,30,21);

if i=5 then
ReadText(UserInput,6,25);

if i=6 then
ReadText(UserInput,12,25);

if i=7 then
ReadText(UserInput,18,25);

if i=8 then
ReadText(UserInput,24,25);


until (UserInput[i]=Answer[i]) or (TimeInMin > GameStartTime+3);

if TimeInMin=GameStartTime+3 then
GotoXY(37,23);
write('Time Up ! You are loss!');
exitt(K);
if K='k' then exit;

end;

if ReadText(UserInput,X,Y)  then
begin
 if UserInput[i] <> Answer[i] then
Get_hint(hint);
if hint=4 then exitt(K);
if K='k' then exit;

if UserInput[1]=Answer[1] then
textcolor(14);
GotoXY(11,13);
write('L') ;              {if the letter is right, then the same  letter in the Display change color}


if UserInput[2]=Answer[2] then
textcolor(14);
GotoXY(11,15);
write('O');


if UserInput[3]=Answer[3] then
textcolor(14);
GotoXY(17,15);
write('C');


if UserInput[4]=Answer[4] then
textcolor(14);
GotoXY(17,17);
write('K');


if UserInput[5]=Answer[5] then
textcolor(14);
GotoXY(17,9);
write('T');


if UserInput[6]=Answer[6] then
textcolor(14);
GotoXY(23,9);
write('O');


if UserInput[7]=Answer[7] then
textcolor(14);
GotoXY(23,11);
write('W');


if UserInput[8]=Answer[8] then
textcolor(14);
GotoXY(29,11);
write('E');


if UserInput=Answer then
GotoXY(37,22);
writeln('You are Win!!');
exitt(K);
if K='k' then exit;

end;



end.









Report
Re: crossword!! Posted by juice88 on 5 Jan 2005 at 9:12 AM
: : : : : : i have some questions about crossword ~
: : : : : : \Please help me!
: : : : : :
: : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : :
: : : : : : 2) I want to know does pascal has this function??
: : : : : : if i input the right answer in the game
: : : : : : then the colour of text will change to another colour~~
: : : : : : How can do this??
: : : : : :
: : : : : : Suggest the simplest way to me~
: : : : : : THZ~
: : : : : :
: : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : :
: : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : :
: : : : THX~
: : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : :
: : : :
: : : :
: : : :
: : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : :
: : OK!The problem has been solved.
: :
: : 2)I think this method is not suitable in my idea.
: : My idea is like that:
: : I had set a display with many letters for the player to choose them.
: : If they choose a right letter, it will change colour.
: :
: : Any other method??
: :
: : 3)How to set a timer that count down 30 minutes.
: :
: :
: Here is a little function I write for you to handle the key presses:
:
: function ReadText(var UserInput: string; const X, Y: integer): boolean;
: { This is a non-blocking user entry function
:   Handles the following key-strokes:
:   - Backspace: removes last character
:   - Enter: Sets the result to true
:   - ASCII Code 32 (space) and upwards are valid characters
:   - Removes extended (multi-byte) keypresses
:   Other features:
:   - Reduces flickering by first checking if the user actually pressed a key
:   - positions the input field at X, Y relative to top-left of the screen
: }
: begin
:   ReadText := false; { Assume a non-enter key }
:   if KeyPressed then { Check for key-press }
:   begin
:     ch := ReadKey; { Get the ASCII key code }
:     case ch of
:       #0..#7: ;
:       #8: Delete(UserInput, Length(UserInput), 1);
:       #9..#12: ;
:       #13: ReadText := true;
:       #14..#31: ;
:       else UserInput := UserInput + ch;
:     end;
:     while KeyPressed do ReadKey; { Remove extended }
:     GotoXY(X, Y); { Show the result at X, Y }
:     write(UserInput);
:   end;
: end;
: 

: It is untested, but should work.
:
Yes.I have found something not understand.
This function is a boolean ,how can it write UserInput??
It juct consider whether the function is true or false~
What different between using function and procedure??

How can I contact you expect in this forum ??

Report
Re: crossword!! Posted by zibadian on 5 Jan 2005 at 10:00 AM
: : : : : : : i have some questions about crossword ~
: : : : : : : \Please help me!
: : : : : : :
: : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : :
: : : : : : : 2) I want to know does pascal has this function??
: : : : : : : if i input the right answer in the game
: : : : : : : then the colour of text will change to another colour~~
: : : : : : : How can do this??
: : : : : : :
: : : : : : : Suggest the simplest way to me~
: : : : : : : THZ~
: : : : : : :
: : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : :
: : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : :
: : : : : THX~
: : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : :
: : : : :
: : : : :
: : : : :
: : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : :
: : : OK!The problem has been solved.
: : :
: : : 2)I think this method is not suitable in my idea.
: : : My idea is like that:
: : : I had set a display with many letters for the player to choose them.
: : : If they choose a right letter, it will change colour.
: : :
: : : Any other method??
: : :
: : : 3)How to set a timer that count down 30 minutes.
: : :
: : :
: : Here is a little function I write for you to handle the key presses:
: :
: : function ReadText(var UserInput: string; const X, Y: integer): boolean;
: : { This is a non-blocking user entry function
: :   Handles the following key-strokes:
: :   - Backspace: removes last character
: :   - Enter: Sets the result to true
: :   - ASCII Code 32 (space) and upwards are valid characters
: :   - Removes extended (multi-byte) keypresses
: :   Other features:
: :   - Reduces flickering by first checking if the user actually pressed a key
: :   - positions the input field at X, Y relative to top-left of the screen
: : }
: : begin
: :   ReadText := false; { Assume a non-enter key }
: :   if KeyPressed then { Check for key-press }
: :   begin
: :     ch := ReadKey; { Get the ASCII key code }
: :     case ch of
: :       #0..#7: ;
: :       #8: Delete(UserInput, Length(UserInput), 1);
: :       #9..#12: ;
: :       #13: ReadText := true;
: :       #14..#31: ;
: :       else UserInput := UserInput + ch;
: :     end;
: :     while KeyPressed do ReadKey; { Remove extended }
: :     GotoXY(X, Y); { Show the result at X, Y }
: :     write(UserInput);
: :   end;
: : end;
: : 

: : It is untested, but should work.
: :
: Yes.I have found something not understand.
: This function is a boolean ,how can it write UserInput??
: It juct consider whether the function is true or false~
: What different between using function and procedure??
:
: How can I contact you expect in this forum ??
:
:
The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
  repeat
  until (ReadText(UserInput, 10, 10)) or (Now = EndTime);

The difference between a function and a procedure is that a function returns a result, while a procedure doesn't. This allows functions to become a part of a larger statement, while procedures are single statements. KeyPressed() is also examples of a function. If KeyPressed was a procedure, I would have had to code the part of the ReadText() function as follows:
begin
  ReadText := false; { Assume a non-enter key }
  KeyPressed(SomeBool);
  if SomeBool then { Check for key-press }
  begin

and add another temporary variable.
The ways to contact me are on My Page here at this site.
Report
Re: crossword!! Posted by juice88 on 6 Jan 2005 at 2:54 AM
: : : : : : : : i have some questions about crossword ~
: : : : : : : : \Please help me!
: : : : : : : :
: : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : :
: : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : if i input the right answer in the game
: : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : How can do this??
: : : : : : : :
: : : : : : : : Suggest the simplest way to me~
: : : : : : : : THZ~
: : : : : : : :
: : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : :
: : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : :
: : : : : : THX~
: : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : :
: : : : : :
: : : : : :
: : : : : :
: : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : :
: : : : OK!The problem has been solved.
: : : :
: : : : 2)I think this method is not suitable in my idea.
: : : : My idea is like that:
: : : : I had set a display with many letters for the player to choose them.
: : : : If they choose a right letter, it will change colour.
: : : :
: : : : Any other method??
: : : :
: : : : 3)How to set a timer that count down 30 minutes.
: : : :
: : : :
: : : Here is a little function I write for you to handle the key presses:
: : :
: : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
: : : { This is a non-blocking user entry function
: : :   Handles the following key-strokes:
: : :   - Backspace: removes last character
: : :   - Enter: Sets the result to true
: : :   - ASCII Code 32 (space) and upwards are valid characters
: : :   - Removes extended (multi-byte) keypresses
: : :   Other features:
: : :   - Reduces flickering by first checking if the user actually pressed a key
: : :   - positions the input field at X, Y relative to top-left of the screen
: : : }
: : : begin
: : :   ReadText := false; { Assume a non-enter key }
: : :   if KeyPressed then { Check for key-press }
: : :   begin
: : :     ch := ReadKey; { Get the ASCII key code }
: : :     case ch of
: : :       #0..#7: ;
: : :       #8: Delete(UserInput, Length(UserInput), 1);
: : :       #9..#12: ;
: : :       #13: ReadText := true;
: : :       #14..#31: ;
: : :       else UserInput := UserInput + ch;
: : :     end;
: : :     while KeyPressed do ReadKey; { Remove extended }
: : :     GotoXY(X, Y); { Show the result at X, Y }
: : :     write(UserInput);
: : :   end;
: : : end;
: : : 

: : : It is untested, but should work.
: : :

: The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
:
:   repeat
:   until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
: 


But when I do it like this??
repeat
ReadText(UserInput,10,10);
until (ReadText(UserInput, 10, 10))

if (ReadText(UserInput, 10, 10)) then
begin
if UserInput<> Answer then <--##
writeln('Loss');
else
writeln('Win');
end;
end.


the program just do the repeat loop.
I think that it is because the UserInput can not be export
,so it can't check the answer.

Report
Re: crossword!! Posted by zibadian on 6 Jan 2005 at 3:15 AM
: : : : : : : : : i have some questions about crossword ~
: : : : : : : : : \Please help me!
: : : : : : : : :
: : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : :
: : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : if i input the right answer in the game
: : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : How can do this??
: : : : : : : : :
: : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : THZ~
: : : : : : : : :
: : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : :
: : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : :
: : : : : : : THX~
: : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : :
: : : : : OK!The problem has been solved.
: : : : :
: : : : : 2)I think this method is not suitable in my idea.
: : : : : My idea is like that:
: : : : : I had set a display with many letters for the player to choose them.
: : : : : If they choose a right letter, it will change colour.
: : : : :
: : : : : Any other method??
: : : : :
: : : : : 3)How to set a timer that count down 30 minutes.
: : : : :
: : : : :
: : : : Here is a little function I write for you to handle the key presses:
: : : :
: : : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
: : : : { This is a non-blocking user entry function
: : : :   Handles the following key-strokes:
: : : :   - Backspace: removes last character
: : : :   - Enter: Sets the result to true
: : : :   - ASCII Code 32 (space) and upwards are valid characters
: : : :   - Removes extended (multi-byte) keypresses
: : : :   Other features:
: : : :   - Reduces flickering by first checking if the user actually pressed a key
: : : :   - positions the input field at X, Y relative to top-left of the screen
: : : : }
: : : : begin
: : : :   ReadText := false; { Assume a non-enter key }
: : : :   if KeyPressed then { Check for key-press }
: : : :   begin
: : : :     ch := ReadKey; { Get the ASCII key code }
: : : :     case ch of
: : : :       #0..#7: ;
: : : :       #8: Delete(UserInput, Length(UserInput), 1);
: : : :       #9..#12: ;
: : : :       #13: ReadText := true;
: : : :       #14..#31: ;
: : : :       else UserInput := UserInput + ch;
: : : :     end;
: : : :     while KeyPressed do ReadKey; { Remove extended }
: : : :     GotoXY(X, Y); { Show the result at X, Y }
: : : :     write(UserInput);
: : : :   end;
: : : : end;
: : : : 

: : : : It is untested, but should work.
: : : :
:
: : The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
: :
: :   repeat
: :   until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
: : 

:
: But when I do it like this??
:
: repeat
: ReadText(UserInput,10,10);
: until (ReadText(UserInput, 10, 10))
: 
: if (ReadText(UserInput, 10, 10)) then
: begin
: if UserInput<> Answer then <--##
: writeln('Loss');
: else
: writeln('Win');
: end;
: end.
: 

:
: the program just do the repeat loop.
: I think that it is because the UserInput can not be export
: ,so it can't check the answer.
:
:
UserInput is being exported, that's what the var before UserInput is for.
The repeat until loop you created will not work, because it has a ReadText() inside it. This way the user might press enter for the inner ReadText() and still remain inside the loop. You can however show the time remaining in the loop, like this:
  repeat
    GotoXY(1,1);
    Writeln(i);
    inc(i);
  until ReadText(UsderInput, 10, 10);
  if UserInput = Answer then
    Writeln('You win')
  else
    Writeln('You lose');

You don't need to call ReadText() in the if-then, because the user doesn't have to enter his answer again. In fact your code will check the answer only if the user presses the enter again within a few milliseconds after the first time.
Run this last code and you'll see what I mean.
Report
Re: crossword!! Posted by juice88 on 6 Jan 2005 at 6:03 AM
: : : : : : : : : : i have some questions about crossword ~
: : : : : : : : : : \Please help me!
: : : : : : : : : :
: : : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : : :
: : : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : : if i input the right answer in the game
: : : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : : How can do this??
: : : : : : : : : :
: : : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : : THZ~
: : : : : : : : : :
: : : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : : :
: : : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : : :
: : : : : : : : THX~
: : : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : : :
: : : : : : OK!The problem has been solved.
: : : : : :
: : : : : : 2)I think this method is not suitable in my idea.
: : : : : : My idea is like that:
: : : : : : I had set a display with many letters for the player to choose them.
: : : : : : If they choose a right letter, it will change colour.
: : : : : :
: : : : : : Any other method??
: : : : : :
: : : : : : 3)How to set a timer that count down 30 minutes.
: : : : : :
: : : : : :
: : : : : Here is a little function I write for you to handle the key presses:
: : : : :
: : : : : function ReadText(var UserInput: string; const X, Y: integer): boolean;
: : : : : { This is a non-blocking user entry function
: : : : :   Handles the following key-strokes:
: : : : :   - Backspace: removes last character
: : : : :   - Enter: Sets the result to true
: : : : :   - ASCII Code 32 (space) and upwards are valid characters
: : : : :   - Removes extended (multi-byte) keypresses
: : : : :   Other features:
: : : : :   - Reduces flickering by first checking if the user actually pressed a key
: : : : :   - positions the input field at X, Y relative to top-left of the screen
: : : : : }
: : : : : begin
: : : : :   ReadText := false; { Assume a non-enter key }
: : : : :   if KeyPressed then { Check for key-press }
: : : : :   begin
: : : : :     ch := ReadKey; { Get the ASCII key code }
: : : : :     case ch of
: : : : :       #0..#7: ;
: : : : :       #8: Delete(UserInput, Length(UserInput), 1);
: : : : :       #9..#12: ;
: : : : :       #13: ReadText := true;
: : : : :       #14..#31: ;
: : : : :       else UserInput := UserInput + ch;
: : : : :     end;
: : : : :     while KeyPressed do ReadKey; { Remove extended }
: : : : :     GotoXY(X, Y); { Show the result at X, Y }
: : : : :     write(UserInput);
: : : : :   end;
: : : : : end;
: : : : : 

: : : : : It is untested, but should work.
: : : : :
: :
: : : The function also exports the UserInput parameter (it's a var parameter). The function returns true if the user presses ENTER. You can use this function like a readln if you place it in a repeat-until loop. Inside that loop, you can then perform other code, such as checking for time. Here is an example:
: : :
: : :   repeat
: : :   until (ReadText(UserInput, 10, 10)) or (Now = EndTime);
: : : 

: :
: : But when I do it like this??
: :
: : repeat
: : ReadText(UserInput,10,10);
: : until (ReadText(UserInput, 10, 10))
: : 
: : if (ReadText(UserInput, 10, 10)) then
: : begin
: : if UserInput<> Answer then <--##
: : writeln('Loss');
: : else
: : writeln('Win');
: : end;
: : end.
: : 

: :
: : the program just do the repeat loop.
: : I think that it is because the UserInput can not be export
: : ,so it can't check the answer.
: :
: :
: UserInput is being exported, that's what the var before UserInput is for.
: The repeat until loop you created will not work, because it has a ReadText() inside it. This way the user might press enter for the inner ReadText() and still remain inside the loop. You can however show the time remaining in the loop, like this:
:
:   repeat
:     GotoXY(1,1);
:     Writeln(i);
:     inc(i);
:   until ReadText(UsderInput, 10, 10);
:   if UserInput = Answer then
:     Writeln('You win')
:   else
:     Writeln('You lose');
: 

: You don't need to call ReadText() in the if-then, because the user doesn't have to enter his answer again. In fact your code will check the answer only if the user presses the enter again within a few milliseconds after the first time.
: Run this last code and you'll see what I mean.
:

Oh ~I see.
Is it like this:
repeat
:     GotoXY(1,1);
:     Writeln(3-(TimeInMin-GameStartTime));
:     inc(3-(TimeInMin-GameStartTime));  <---what is inc??
:   until ReadText(UsderInput, 10, 10) <---But how to move to next question?? 
:   if UserInput[i] <> Answer[i] then
    begin
    Get_hint
    if hint>4 then
     Writeln('You lose')
:   else
:     Writeln('You lose');
end;
end.

Report
Re: crossword!! Posted by zibadian on 6 Jan 2005 at 6:10 AM
: : : : : i have some questions about crossword ~
: : : : : \Please help me!
: : : : :
: : : : : 1) How to set the background colour and text colour in pascal??
: : : : :
: : : : : 2) I want to know does pascal has this function??
: : : : : if i input the right answer in the game
: : : : : then the colour of text will change to another colour~~
: : : : : How can do this??
: : : : :
: : : : : Suggest the simplest way to me~
: : : : : THZ~
: : : : :
: : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : :
: : : : 2: Set the new textcolor and write the answer again at the same location.
: : : :
: : : THX~
: : : BUT I Have a error200 <division by zero> when i set the text colour.
: : :
: : :
: : :
: : :
: : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: :
: OK!The problem has been solved.
:
: 2)I think this method is not suitable in my idea.
: My idea is like that:
: I had set a display with many letters for the player to choose them.
: If they choose a right letter, it will change colour.
:
: Any other method??
:
: 3)How to set a timer that count down 30 minutes.
:
:
Inc is short for increase, which should be explained in the help files.
ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
Report
Re: crossword!! Posted by juice88 on 6 Jan 2005 at 7:44 AM
This message was edited by juice88 at 2005-1-6 7:45:47

This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : i have some questions about crossword ~
: : : : : : \Please help me!
: : : : : :
: : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : :
: : : : : : 2) I want to know does pascal has this function??
: : : : : : if i input the right answer in the game
: : : : : : then the colour of text will change to another colour~~
: : : : : : How can do this??
: : : : : :
: : : : : : Suggest the simplest way to me~
: : : : : : THZ~
: : : : : :
: : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : :
: : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : :
: : : : THX~
: : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : :
: : : :
: : : :
: : : :
: : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : :
: : OK!The problem has been solved.
: :
: : 2)I think this method is not suitable in my idea.
: : My idea is like that:
: : I had set a display with many letters for the player to choose them.
: : If they choose a right letter, it will change colour.
: :
: : Any other method??
: :
: : 3)How to set a timer that count down 30 minutes.
: :
: :
: Inc is short for increase, which should be explained in the help files.
: ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.


But how the program know when should it increase??
What is the use of this inc() comment in the crossword??

NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.

layout
###########################################
#     #      #      #      #       #      #
#     #      #      #      #       #      #
###########################################

There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .

So how can the function work in this way??

:





Report
Re: crossword!! Posted by juice88 on 7 Jan 2005 at 7:56 AM
: This message was edited by juice88 at 2005-1-6 7:45:47

: This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : : i have some questions about crossword ~
: : : : : : : \Please help me!
: : : : : : :
: : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : :
: : : : : : : 2) I want to know does pascal has this function??
: : : : : : : if i input the right answer in the game
: : : : : : : then the colour of text will change to another colour~~
: : : : : : : How can do this??
: : : : : : :
: : : : : : : Suggest the simplest way to me~
: : : : : : : THZ~
: : : : : : :
: : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : :
: : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : :
: : : : : THX~
: : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : :
: : : : :
: : : : :
: : : : :
: : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : :
: : : OK!The problem has been solved.
: : :
: : : 2)I think this method is not suitable in my idea.
: : : My idea is like that:
: : : I had set a display with many letters for the player to choose them.
: : : If they choose a right letter, it will change colour.
: : :
: : : Any other method??
: : :
: : : 3)How to set a timer that count down 30 minutes.
: : :
: : :
: : Inc is short for increase, which should be explained in the help files.
: : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
:
:
: But how the program know when should it increase??
: What is the use of this inc() comment in the crossword??
:
: NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.
:
: layout
:
: ###########################################
: #     #      #      #      #       #      #
: #     #      #      #      #       #      #
: ###########################################
: 

: There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .
:
: So how can the function work in this way??
:
: :
:

??
Report
Re: crossword!! Posted by zibadian on 7 Jan 2005 at 1:31 PM
: : This message was edited by juice88 at 2005-1-6 7:45:47

: : This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : : : i have some questions about crossword ~
: : : : : : : : \Please help me!
: : : : : : : :
: : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : :
: : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : if i input the right answer in the game
: : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : How can do this??
: : : : : : : :
: : : : : : : : Suggest the simplest way to me~
: : : : : : : : THZ~
: : : : : : : :
: : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : :
: : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : :
: : : : : : THX~
: : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : :
: : : : : :
: : : : : :
: : : : : :
: : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : :
: : : : OK!The problem has been solved.
: : : :
: : : : 2)I think this method is not suitable in my idea.
: : : : My idea is like that:
: : : : I had set a display with many letters for the player to choose them.
: : : : If they choose a right letter, it will change colour.
: : : :
: : : : Any other method??
: : : :
: : : : 3)How to set a timer that count down 30 minutes.
: : : :
: : : :
: : : Inc is short for increase, which should be explained in the help files.
: : : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
: :
: :
: : But how the program know when should it increase??
: : What is the use of this inc() comment in the crossword??
: :
: : NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.
: :
: : layout
: :
: : ###########################################
: : #     #      #      #      #       #      #
: : #     #      #      #      #       #      #
: : ###########################################
: : 

: : There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .
: :
: : So how can the function work in this way??
: :
: : :
: :
:
: ??
:
I would use the normal KeyPressed/Readkey combination for that:
  repeat
    ch := '';
    repeat
      { Show time to user }
      if CurrentTime > EndTime then
        Break;
      if KeyPressed then
        ch := ReadKey;
    until ch <> '';
    if CurrentTime > EndTime then
      Break;
  until ch = AnswerLetter;

You might want to place this loop into a function with the AnswerLetter as parameter and the user input as result.
The red if-thens's need some work. These are to ensure that the user runs out of time during the input.
Report
Re: crossword!! Posted by juice88 on 7 Jan 2005 at 9:33 PM
: : : This message was edited by juice88 at 2005-1-6 7:45:47

: : : This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : : : : i have some questions about crossword ~
: : : : : : : : : \Please help me!
: : : : : : : : :
: : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : :
: : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : if i input the right answer in the game
: : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : How can do this??
: : : : : : : : :
: : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : THZ~
: : : : : : : : :
: : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : :
: : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : :
: : : : : : : THX~
: : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : :
: : : : : OK!The problem has been solved.
: : : : :
: : : : : 2)I think this method is not suitable in my idea.
: : : : : My idea is like that:
: : : : : I had set a display with many letters for the player to choose them.
: : : : : If they choose a right letter, it will change colour.
: : : : :
: : : : : Any other method??
: : : : :
: : : : : 3)How to set a timer that count down 30 minutes.
: : : : :
: : : : :
: : : : Inc is short for increase, which should be explained in the help files.
: : : : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
: : :
: : :
: : : But how the program know when should it increase??
: : : What is the use of this inc() comment in the crossword??
: : :
: : : NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.
: : :
: : : layout
: : :
: : : ###########################################
: : : #     #      #      #      #       #      #
: : : #     #      #      #      #       #      #
: : : ###########################################
: : : 

: : : There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .
: : :
: : : So how can the function work in this way??
: : :
: : : :
: : :
: :
: : ??
: :
: I would use the normal KeyPressed/Readkey combination for that:
:
:   repeat
:     ch := '';
:     repeat
:       { Show time to user }
:       if CurrentTime > EndTime then
:         Break;
:       if KeyPressed then
:         ch := ReadKey;
:     until ch <> '';
:     if CurrentTime > EndTime then
:       Break;
:   until ch = AnswerLetter;
: 

: You might want to place this loop into a function with the AnswerLetter as parameter and the user input as result.
: The red if-thens's need some work. These are to ensure that the user runs out of time during the input.
:
I get your point !!
Am I right??

function UserInput (var AnswerLetter:char;X,Y,A,B:integer): string ;
var
TimeLeft,GameStartTime,hint:integer ;
k:char ;
UserEntered : boolean;
begin
GameStartTime := TimeInMin;
repeat
UserInput:='';
  repeat
  TimeLeft:=(3-(TimeInMin-GameStartTime));
  GotoXY(8,34);
  write(TimeLeft);
  if  TimeLeft = 0 then
  begin
  GotoXY(37,23);
  write('Time Up ! You are loss!');
  exitt(k);
  end;
  if keypressed then
  begin
  ch := Readkey ;
  case ch of
      {show answer when user press Tab}
      #9: write('Answer is CLOCK TOWER. (Press ESC to exit)');  
      #13:UserEntered := true;  {User must input the letter then press enter}
      #27: exit ;  {press ESC then exit}

    end;
    while KeyPressed do ReadKey; { Remove extended }
    GotoXY(X,Y); {show the Letter that User entered in the boxes}
    write(ch);
    end;
  until UserEntered; {user press enter}
  if ch <> AnswerLetter then
  Get_hint(hint);
if  TimeLeft = 0 then   {time up then loss}
begin
  GotoXY(37,23);
  write('Time Up ! You are loss!');
  exitt(k);
  end;
until ch = AnswerLetter ;
Textcolor(14);
GotoXY (X,Y);
write(ch);
GotoXY (A,B);   {change color in Display}
write(ch)   ;
end;


But there are some problem.
I don't Know why I have'nt pressed enter, the program changed the letter in Display.
And it can't get hint.

The Gethint procedure is show below:
procedure Get_hint (var count:integer);
var k:char;
begin
count:=0;
if ch <> AnswerLetter then 
count:=count+1;
if count=1 then
GotoXY(9,29);
if count=2 then
GotoXY(9,30);
if count=3 then
GotoXY(9,31);
if count=4 then
GotoXY(37,23);
case count of
1:writeln('Hint 1');
2:writeln('Hint 2');
3:writeln('Hint 3');
end;
if count=4 then   { no chance}
 begin
writeln('You are loss!!') ;
   exitt(k);
   end;
   end;


I don't know why??
Is it the red statement is wrong??

Thank!!



Report
Re: crossword!! Posted by zibadian on 10 Jan 2005 at 9:50 AM
: : : : This message was edited by juice88 at 2005-1-6 7:45:47

: : : : This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : : : : : i have some questions about crossword ~
: : : : : : : : : : \Please help me!
: : : : : : : : : :
: : : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : : :
: : : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : : if i input the right answer in the game
: : : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : : How can do this??
: : : : : : : : : :
: : : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : : THZ~
: : : : : : : : : :
: : : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : : :
: : : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : : :
: : : : : : : : THX~
: : : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : : :
: : : : : : OK!The problem has been solved.
: : : : : :
: : : : : : 2)I think this method is not suitable in my idea.
: : : : : : My idea is like that:
: : : : : : I had set a display with many letters for the player to choose them.
: : : : : : If they choose a right letter, it will change colour.
: : : : : :
: : : : : : Any other method??
: : : : : :
: : : : : : 3)How to set a timer that count down 30 minutes.
: : : : : :
: : : : : :
: : : : : Inc is short for increase, which should be explained in the help files.
: : : : : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
: : : :
: : : :
: : : : But how the program know when should it increase??
: : : : What is the use of this inc() comment in the crossword??
: : : :
: : : : NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.
: : : :
: : : : layout
: : : :
: : : : ###########################################
: : : : #     #      #      #      #       #      #
: : : : #     #      #      #      #       #      #
: : : : ###########################################
: : : : 

: : : : There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .
: : : :
: : : : So how can the function work in this way??
: : : :
: : : : :
: : : :
: : :
: : : ??
: : :
: : I would use the normal KeyPressed/Readkey combination for that:
: :
: :   repeat
: :     ch := '';
: :     repeat
: :       { Show time to user }
: :       if CurrentTime > EndTime then
: :         Break;
: :       if KeyPressed then
: :         ch := ReadKey;
: :     until ch <> '';
: :     if CurrentTime > EndTime then
: :       Break;
: :   until ch = AnswerLetter;
: : 

: : You might want to place this loop into a function with the AnswerLetter as parameter and the user input as result.
: : The red if-thens's need some work. These are to ensure that the user runs out of time during the input.
: :
: I get your point !!
: Am I right??
:
:
: function UserInput (var AnswerLetter:char;X,Y,A,B:integer): string ;
: var
: TimeLeft,GameStartTime,hint:integer ;
: k:char ;
: UserEntered : boolean;
: begin
: GameStartTime := TimeInMin;
: repeat
: UserInput:='';
:   repeat
:   TimeLeft:=(3-(TimeInMin-GameStartTime));
:   GotoXY(8,34);
:   write(TimeLeft);
:   if  TimeLeft = 0 then
:   begin
:   GotoXY(37,23);
:   write('Time Up ! You are loss!');
:   exitt(k);
:   end;
:   if keypressed then
:   begin
:   ch := Readkey ;
:   case ch of
:       {show answer when user press Tab}
:       #9: write('Answer is CLOCK TOWER. (Press ESC to exit)');  
:       #13:UserEntered := true;  {User must input the letter then press enter}
:       #27: exit ;  {press ESC then exit}
: 
:     end;
:     while KeyPressed do ReadKey; { Remove extended }
:     GotoXY(X,Y); {show the Letter that User entered in the boxes}
:     write(ch);
:     end;
:   until UserEntered; {user press enter}
:   if ch <> AnswerLetter then
:   Get_hint(hint);
: if  TimeLeft = 0 then   {time up then loss}
: begin
:   GotoXY(37,23);
:   write('Time Up ! You are loss!');
:   exitt(k);
:   end;
: until ch = AnswerLetter ;
: Textcolor(14);
: GotoXY (X,Y);
: write(ch);
: GotoXY (A,B);   {change color in Display}
: write(ch)   ;
: end;
: 
: 

: But there are some problem.
: I don't Know why I have'nt pressed enter, the program changed the letter in Display.
: And it can't get hint.
:
: The Gethint procedure is show below:
:
: procedure Get_hint (var count:integer);
: var k:char;
: begin
: count:=0;
: if ch <> AnswerLetter then 
: count:=count+1;
: if count=1 then
: GotoXY(9,29);
: if count=2 then
: GotoXY(9,30);
: if count=3 then
: GotoXY(9,31);
: if count=4 then
: GotoXY(37,23);
: case count of
: 1:writeln('Hint 1');
: 2:writeln('Hint 2');
: 3:writeln('Hint 3');
: end;
: if count=4 then   { no chance}
:  begin
: writeln('You are loss!!') ;
:    exitt(k);
:    end;
:    end;
: 

:
: I don't know why??
: Is it the red statement is wrong??
:
: Thank!!
:
:
:
:
THe Get_Hint will only show the first or no hint, depending on the condition in the red statement. If you run that code in your head and keep track of count as it changes in each line, you will see why.
Report
Re: crossword!! Posted by juice88 on 11 Jan 2005 at 6:11 AM
This message was edited by juice88 at 2005-1-11 8:50:18

This message was edited by juice88 at 2005-1-11 6:14:26

This message was edited by juice88 at 2005-1-11 6:11:48

: : : This message was edited by juice88 at 2005-1-6 7:45:47

: : : This message was edited by juice88 at 2005-1-6 7:45:7

: : : : : : : : : i have some questions about crossword ~
: : : : : : : : : \Please help me!
: : : : : : : : :
: : : : : : : : : 1) How to set the background colour and text colour in pascal??
: : : : : : : : :
: : : : : : : : : 2) I want to know does pascal has this function??
: : : : : : : : : if i input the right answer in the game
: : : : : : : : : then the colour of text will change to another colour~~
: : : : : : : : : How can do this??
: : : : : : : : :
: : : : : : : : : Suggest the simplest way to me~
: : : : : : : : : THZ~
: : : : : : : : :
: : : : : : : : 1: TextColor() and TextBackground() in the CRT unit.
: : : : : : : :
: : : : : : : : 2: Set the new textcolor and write the answer again at the same location.
: : : : : : : :
: : : : : : : THX~
: : : : : : : BUT I Have a error200 <division by zero> when i set the text colour.
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : If you are using TP, have you patched your CRT unit? If not search for CRT patch on google, and install that. It is necessary for fast computers.
: : : : : :
: : : : : OK!The problem has been solved.
: : : : :
: : : : : 2)I think this method is not suitable in my idea.
: : : : : My idea is like that:
: : : : : I had set a display with many letters for the player to choose them.
: : : : : If they choose a right letter, it will change colour.
: : : : :
: : : : : Any other method??
: : : : :
: : : : : 3)How to set a timer that count down 30 minutes.
: : : : :
: : : : :
: : : : Inc is short for increase, which should be explained in the help files.
: : : : ReadText() is designed to get the whole answer in 1 loop, then you can check it and ask the user the next question.
: : :
: : :
: : : But how the program know when should it increase??
: : : What is the use of this inc() comment in the crossword??
: : :
: : : NO~ I want to get each of the letter in loop,then i can check it one by one and move to next letter if the user entered is right.
: : :
: : : layout
: : :
: : : ###########################################
: : : #     #      #      #      #       #      #
: : : #     #      #      #      #       #      #
: : : ###########################################
: : : 

: : : There are 6 boxes, the user need to enter the first letter in the first box and press enter and then check it .If the letter is right ,then (GotoXY) move to next box and enter the second letter......Therefore the coordinateXY of each boxes are different .
: : :
: : : So how can the function work in this way??
: : :
: : : :
: : :
: :
: : ??
: :
: I would use the normal KeyPressed/Readkey combination for that:
:
:   repeat
:     ch := '';
:     repeat
:       { Show time to user }
:       if CurrentTime > EndTime then
:         Break;
:       if KeyPressed then
:         ch := ReadKey;
:     until ch <> '';
:     if CurrentTime > EndTime then
:       Break;
:   until ch = AnswerLetter;
: 

: You might want to place this loop into a function with the AnswerLetter as parameter and the user input as result.
: The red if-thens's need some work. These are to ensure that the user runs out of time during the input.
:



: THe Get_Hint will only show the first or no hint, depending on the condition in the red statement. If you run that code in your head and keep track of count as it changes in each line, you will see why.
:
Is it because of the code count:=0??
I have put the declaration count:integer in the heading to becomes the global variable.
How can I solve it??

How about my first question??
why I have'nt pressed enter, the program changed color of the letter in Display.
I want it to change the color after user input right letter~







Report
Re: crossword!! Posted by Xaser-3 on 6 Jan 2005 at 5:39 PM
: i have some questions about crossword ~
: \Please help me!
:
: 1) How to set the background colour and text colour in pascal??
:
: 2) I want to know does pascal has this function??
: if i input the right answer in the game
: then the colour of text will change to another colour~~
: How can do this??
:
: Suggest the simplest way to me~
: THZ~
:

To set the background colour in Pascal use this: textbackground(colour); {colour is where you have to put your colour which you want } and for text colour use this: textcolor(colour);

Yes no.2 can be done in Pascal but I don't know how.

Xaser-3



Report
Re: crossword!! Posted by zibadian on 7 Jan 2005 at 5:09 AM
: : i have some questions about crossword ~
: : \Please help me!
: :
: : 1) How to set the background colour and text colour in pascal??
: :
: : 2) I want to know does pascal has this function??
: : if i input the right answer in the game
: : then the colour of text will change to another colour~~
: : How can do this??
: :
: : Suggest the simplest way to me~
: : THZ~
: :
:
: To set the background colour in Pascal use this: textbackground(colour); {colour is where you have to put your colour which you want } and for text colour use this: textcolor(colour);
:
: Yes no.2 can be done in Pascal but I don't know how.
:
: Xaser-3
:
Have you read this post http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=16&MsgID=281521&Setting=A0001F2002 ? It is basically the same answer you gave here.
Report
Re: crossword!! Posted by superlemon on 14 Jan 2005 at 9:03 AM
HIHI~
I also need to write this program.
I have some problems need for help.
Please help me!
I want to ask that can I use CRT in TB WINDOWS 1.5??
Report
Re: crossword!! Posted by juice88 on 7 Jan 2005 at 7:55 AM
: : i have some questions about crossword ~
: : \Please help me!
: :
: : 1) How to set the background colour and text colour in pascal??
: :
: : 2) I want to know does pascal has this function??
: : if i input the right answer in the game
: : then the colour of text will change to another colour~~
: : How can do this??
: :
: : Suggest the simplest way to me~
: : THZ~
: :
:
: To set the background colour in Pascal use this: textbackground(colour); {colour is where you have to put your colour which you want } and for text colour use this: textcolor(colour);
:
: Yes no.2 can be done in Pascal but I don't know how.
:
: Xaser-3
:
: I just use write() and GotoXY() to do .~
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.