2
2
24r32017-04-30 00:00:10
Pascal
24r3, 2017-04-30 00:00:10

How to break a loop in pascal with a specific key?

There is a loop that displays text, I need something to stop when the "arrow to the right" key is pressed.
How to implement it?
For example:

var go:boolean;
begingo
:=true;
while go=true do
begin
writeln();
writeln('00');
writeln('00');
sleep(100);
end;
end.

Additional question: how to replace
writeln('00');
writeln('00');

an expression similar in meaning, but in one line as in C ++?
cout << "00 \n 00"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2017-04-30
@24r3

1) Add inside the loop

if KeyPressed then 
   begin
   c:=ReadKey;
   if c=#0 then
      begin
      c:=ReadKey;
      if c=#77 then go:=False
      end
   end

2) writeln('00'+#13#10+'00')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question