comp.lang.ada
 help / color / mirror / Atom feed
* wait does not perform as expected
@ 2023-02-22 16:34 Daniel Gaudry
  2023-02-22 17:36 ` Niklas Holsti
  2023-02-24 21:16 ` Jeffrey R.Carter
  0 siblings, 2 replies; 18+ messages in thread
From: Daniel Gaudry @ 2023-02-22 16:34 UTC (permalink / raw)


hi
the following code :


with Gnat.Os_Lib;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;
with Ada.Strings.Maps.Constants;
 with ada.text_io;
with Ada.Strings;


 procedure Hit_Return_To_Continue(Header     : in String   := "HIT RETURN TO CONTINUE";
                                    Mandatory  : in Boolean  := False;
                                    Skip_After : in Duration := 0.0)
      is

      Char  : Character := ' ';
      Hit   : Boolean   := True;
      Timer : Duration  := 0.0;

      begin

      -- ANYTHING TO DO ?
      if Mandatory
         then
          ada.text_io.Put(Header);

         -- ANY WAITING PERIOD TO DISPLAY ?
         if Skip_After > 0.0
            then

            -- KEEP THE USER'S ATTENTION
            while Timer < Skip_After loop
               Timer := 1.0 + @;
               delay 1.0;
               ada.text_io.Put(Natural(Skip_After - Timer)'Img);

               --USER ENDS THE WAITING PERIOD  BEFORE IT'S END ?


               TIO.LOOK_AHEAD(ITEM          => CHAR,
                              END_OF_LINE   => HIT);
               
                 ada.text_io.GET_IMMEDIATE(ITEM      => CHAR,
                                    AVAILABLE => HIT);
                  IF HIT THEN
                     RETURN;
                  END IF;

            end loop;

            -- USER WAITED FOR THE WHOLE  WAITING PERIOD
            -- LET HIM READ THE ZERO ON THE SCREEN

            delay 1.0;
            return;
         end if;

         Atio.Get_Immediate(Item      => Char,
                            Available => Hit);

         Atio.New_Line(Spacing => 1);

      end if;

   end Hit_Return_To_Continue;




the following call:

Hit_Return_To_Continue(Header        => "HIT RETURN TO CONTINUE",
                                           Mandatory  => true,
                                          Skip_After    => 5.0);

does not return if the user hits a key before the end of the countdown.

Can anybody help
Best regards

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-02-24 21:16 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 16:34 wait does not perform as expected Daniel Gaudry
2023-02-22 17:36 ` Niklas Holsti
2023-02-23 14:26   ` AdaMagica
2023-02-23 14:32     ` AdaMagica
2023-02-23 14:33     ` Daniel Gaudry
2023-02-23 14:39       ` AdaMagica
2023-02-23 17:15       ` Niklas Holsti
2023-02-23 17:35     ` Niklas Holsti
2023-02-23 17:49       ` Niklas Holsti
2023-02-23 18:14       ` Dmitry A. Kazakov
2023-02-23 18:29         ` Niklas Holsti
2023-02-23 18:47           ` Daniel Gaudry
2023-02-23 19:08             ` Niklas Holsti
2023-02-23 19:31             ` Niklas Holsti
2023-02-23 20:41           ` Dmitry A. Kazakov
2023-02-24 15:10             ` AdaMagica
2023-02-24 18:23               ` Niklas Holsti
2023-02-24 21:16 ` Jeffrey R.Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox