Board index » delphi » Case Statement Help

Case Statement Help

Anyone knows why this statement cannot execute when I type the
corresponding letter in crt mode...? Do I have to use the keycode for
the letters?

Pier.

procedure detectchar;
  var i: integer ; ch1 : char;
  begin
  readln;
  ch1:= readkey;
    case ch1 of
      'c': begin
           gotoxy(74, 10); textcolor(lightred+blink); write(chr(27));
delay(1000);
           end;
      'B': begin
           gotoxy(74, 13); textcolor(lightred+blink); write(chr(27));
delay(1000);
           end;
      'F': begin
           gotoxy(74, 16); textcolor(lightred+blink); write(chr(27));
delay(1000);
           end;
      'R': begin
           gotoxy(74, 16); textcolor(lightred+blink); write(chr(27));
delay(1000);
           end;
    end;

 

Re:Case Statement Help


Quote
Pier wrote:

> Anyone knows why this statement cannot execute when I type the
> corresponding letter in crt mode...? Do I have to use the keycode for
> the letters?

> Pier.

> procedure detectchar;
>   var i: integer ; ch1 : char;
>   begin
>   readln;

here you "eat up" any kbd entry until Enter. Remove this readln;

Quote
>   ch1:= readkey;
>     case ch1 of
>       'c': begin

---- snip
btw: avoid using the Delay procedure! You will get any
amount of troubles. Look in the TP-links page for FAQ,
timing related subjects.

Quote
> delay(1000);
>            end;
>     end;

Franz Glaser
http://www.geocities.com/SiliconValley/2926/tp.html

Other Threads