[fpc-pascal] strange behaviour of readkey...or not
Florian Klaempfl
F.Klaempfl at gmx.de
Mon Jun 20 19:37:37 CEST 2005
Darius Blaszijk wrote:
> Hi there,
>
> I have a console app that reads keys being pressed and then does some
> action. In short it would be like this:
>
> repeat
> if fileage(myfile) <> imyfile then
> begin
> writeln('file changed');
> imyfile := fileage(myfile);
> end;
>
> ch := readkey;
> until ch = 'q'
>
> So what I want is that the fileage test is done continously and when a user
> presses a key some other procedure is executed. But the problem is that when
> "ch := readkey" is reached, the app seems to stay waiting until a key is
> pressed. In other words it only does the fileage test when I press a key
> other than q. In my example the fileage test is only done once.
>
> Am I under the wrong impression that I should pull it off using readkey??
> What is the alternative??
Do check of keypressed first:
http://www.freepascal.org/docs-html/rtl/crt/keypressed.html
More information about the fpc-pascal
mailing list