comp.lang.ada
 help / color / mirror / Atom feed
From: Daniel Gaudry <gaudry.dg@gmail.com>
Subject: Re: wait does not perform as expected
Date: Thu, 23 Feb 2023 06:33:33 -0800 (PST)	[thread overview]
Message-ID: <6eacc599-b9a9-4c89-9122-862825d23423n@googlegroups.com> (raw)
In-Reply-To: <75c3990e-eaab-47eb-bdba-3827b9fd4751n@googlegroups.com>

On Thursday, February 23, 2023 at 3:26:09 PM UTC+1, AdaMagica wrote:
> 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.


Hi,
 Many thanks for your time and answers
My problem under ubuntu is that get_immediate pauses the program if no key is hit.
Therefore available is not set and this little routine cannot perform as I want.
Any idea on how i can write such a simple routine that works ??
Best regards

  parent reply	other threads:[~2023-02-23 14:33 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
2023-02-23 14:32     ` AdaMagica
2023-02-23 14:33     ` Daniel Gaudry [this message]
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