comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: wait does not perform as expected
Date: Thu, 23 Feb 2023 06:26:07 -0800 (PST)	[thread overview]
Message-ID: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com> (raw)
In-Reply-To: <k5n243Fe43nU1@mid.individual.net>

Niklas Holsti schrieb am Mittwoch, 22. Februar 2023 um 18:36:06 UTC+1:
> On my system, Get_Immediate does /not/ use the inputs collected (but not 
> "consumed") by Look_Ahead, but instead checks if there are _new_ input 
> keystrokes. If there are none, Get_Immediate returns "not Available" 
> (Hit is False) and so the loop continues.

Are you sure? With GNAT Community 2021 (20210519-103) targeting x86_64-w64-mingw32,

  loop
    Look_Ahead    (Char, EoL);  Put ("Look_Ahead:    '" & Char & "', End_of_Line => " & EoL'Image);  New_Line;
    Get_Immediate (Char, Avl);  Put ("Get_Immediate: '" & Char & "', Available   => " & Avl'Image);  New_Line;
  end loop;

I get:

ab x<RETRUN>
Look_Ahead:    'a', End_of_Line => FALSE
Get_Immediate: 'a', Available   => TRUE
Look_Ahead:    'b', End_of_Line => FALSE
Get_Immediate: 'b', Available   => TRUE
Look_Ahead:    ' ', End_of_Line => FALSE
Get_Immediate: ' ', Available   => TRUE
Look_Ahead:    'x', End_of_Line => FALSE
Get_Immediate: 'x', Available   => TRUE
Look_Ahead:    '0', End_of_Line => TRUE
Get_Immediate: '                                          <- This is the EoL
', Available   => TRUE

So Get_Immediate returns the next not yet consumed character. This is inline with A.10.7(12/3):
If a character, either control or graphic, is available from the specified File or the default input file, then the character is read; Available is True and Item contains the value of this character. If a character is not available, then Available is False and the value of Item is not specified.

  reply	other threads:[~2023-02-23 14:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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