comp.lang.ada
 help / color / mirror / Atom feed
* Troubles : New_Page & Get_Immediate
@ 1997-10-17  0:00 Ray Tindall
  1997-10-18  0:00 ` Jerry van Dijk
  1997-10-18  0:00 ` Jerry van Dijk
  0 siblings, 2 replies; 6+ messages in thread
From: Ray Tindall @ 1997-10-17  0:00 UTC (permalink / raw)



Help for a novice?

Using Ada95 and the GW-Gnat compiler.

When trying to use New_Page as in
   New_Page;
to simply refresh the screen in output of text to the screen all I'm
getting is a weird symbol, the control character that represents a page
terminator I guess.  Does anyone know why and or if there is a specific way
it must be used or if it's inappropriate to do what I'm trying.

The LRM states that Get_Immediate can be used to get a character from the
keyboard immediately ie. without the enter key.   But says should be used
with 'unbuffered' input.   Are there any references or suggestions as to
how to do low_level IO or 'unbuffered' input to do this.  End goal to have
something like the well known 'hit any key to continue'.





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

* Re: Troubles : New_Page & Get_Immediate
  1997-10-17  0:00 Troubles : New_Page & Get_Immediate Ray Tindall
  1997-10-18  0:00 ` Jerry van Dijk
@ 1997-10-18  0:00 ` Jerry van Dijk
  1997-10-20  0:00   ` Anonymous
  1997-10-20  0:00   ` John English
  1 sibling, 2 replies; 6+ messages in thread
From: Jerry van Dijk @ 1997-10-18  0:00 UTC (permalink / raw)



In article <01bcdae4$3f70ffa0$0f02000a@default> bjyxxl@echidna.stu.cowan.edu.au writes:

>When trying to use New_Page as in
>   New_Page;
>to simply refresh the screen in output of text to the screen all I'm
>getting is a weird symbol

As New_Page suggests, this is a printer-like command. The funny character
you are seeing is called the 'form-feed' code, instructing the printer
to move to the next page.

On some consoles, sending a form-feed will actually clear the screen,
on others it will simply display the character. On Win95 (if that is
what you are using) the latter is the case.

A very simple solution is:

   Num_Rows : constant := 25; -- number of screen rows;

   procedure Clear_Screen is
   begin
      for I in 1 .. Num_Rows loop
         New_Line;
      end loop;
   end Clear_Screen;

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




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

* Re: Troubles : New_Page & Get_Immediate
  1997-10-17  0:00 Troubles : New_Page & Get_Immediate Ray Tindall
@ 1997-10-18  0:00 ` Jerry van Dijk
  1997-10-18  0:00 ` Jerry van Dijk
  1 sibling, 0 replies; 6+ messages in thread
From: Jerry van Dijk @ 1997-10-18  0:00 UTC (permalink / raw)



In article <01bcdae4$3f70ffa0$0f02000a@default> bjyxxl@echidna.stu.cowan.edu.au writes:

>The LRM states that Get_Immediate can be used to get a character from the
>keyboard immediately ie. without the enter key.   But says should be used
>with 'unbuffered' input.   Are there any references or suggestions as to
>how to do low_level IO or 'unbuffered' input to do this.  End goal to have
>something like the well known 'hit any key to continue'.

As this was asked twice:

a) Get_Immediate comes in two flavors: blocking and non-blocking.

   The blocking form waits until a key is pressed befor returning

   The non-blocking form returns immediately, reporting if a keypress
   was detected.

   Here's a simple example of both:

      with Ada.Text_IO; use Ada.Text_IO;

      procedure Test is
         C         : Character;
         Available : Boolean := False;
      begin

         -- Waiting for a key pressed - blocking
         Put ("Press almost any key to continu: ");
         Get_Immediate(C);
         New_Line;
         Put_Line ("Ok, continuing...");

         -- Polling for a key pressed - non-blocking
         Put ("Again waiting for some keypress: ");
         While not Available loop
            -- Do useful things here
            Get_Immediate (C, Available);
         end loop;
         New_Line;
         Put_Line ("Ok, thanks for pressing a key.");
      end Test;

The buffered/unbufferd issue gives a compiler the option of
not implementing this, but wait for an Enter key to be
pressed first.

Fortunately for you, both OA Special and GNAT support the
(IMHO) proper behavior with their Win95/NT compilers.

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




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

* Re: Troubles : New_Page & Get_Immediate
  1997-10-18  0:00 ` Jerry van Dijk
  1997-10-20  0:00   ` Anonymous
@ 1997-10-20  0:00   ` John English
  1 sibling, 0 replies; 6+ messages in thread
From: John English @ 1997-10-20  0:00 UTC (permalink / raw)



Jerry van Dijk (jerry@jvdsys.nextjk.stuyts.nl) wrote:
:    Num_Rows : constant := 25; -- number of screen rows;

:    procedure Clear_Screen is
:    begin
:       for I in 1 .. Num_Rows loop
:          New_Line;
:       end loop;
:    end Clear_Screen;

... or of course just "New_Line(Num_Rows)" instead of "Clear_Screen".

---------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.comp.it.bton.ac.uk/je
 Dept. of Computing        | fax: (+44) 1273 642405
 University of Brighton    |
---------------------------------------------------------------




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

* Re: Troubles : New_Page & Get_Immediate
  1997-10-18  0:00 ` Jerry van Dijk
@ 1997-10-20  0:00   ` Anonymous
  1997-10-21  0:00     ` Jerry van Dijk
  1997-10-20  0:00   ` John English
  1 sibling, 1 reply; 6+ messages in thread
From: Anonymous @ 1997-10-20  0:00 UTC (permalink / raw)



<01bcdae4$3f70ffa0$0f02000a@default>

On Sat, 18 Oct 97 07:22:54 GMT, jerry@jvdsys.nextjk.stuyts.nl (Jerry van
Dijk) wrote:
>...
> 
> A very simple solution is:
> 
>    Num_Rows : constant := 25; -- number of screen rows;
> 
>    procedure Clear_Screen is
>    begin
>       for I in 1 .. Num_Rows loop
>          New_Line;
>       end loop;
>    end Clear_Screen;
> 

Or simply

   New_Line (Spacing => Num_Rows);

Jeff Carter  PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail

Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/




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

* Re: Troubles : New_Page & Get_Immediate
  1997-10-20  0:00   ` Anonymous
@ 1997-10-21  0:00     ` Jerry van Dijk
  0 siblings, 0 replies; 6+ messages in thread
From: Jerry van Dijk @ 1997-10-21  0:00 UTC (permalink / raw)



In article <199710201340.PAA11416@basement.replay.com> nobody@REPLAY.COM writes:

>   New_Line (Spacing => Num_Rows);

And before another dozen simular postings arrive <g> let me point out that
I was not trying to advertise a solution, just pointing in a direction.

Jerry.

--

-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




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

end of thread, other threads:[~1997-10-21  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-17  0:00 Troubles : New_Page & Get_Immediate Ray Tindall
1997-10-18  0:00 ` Jerry van Dijk
1997-10-18  0:00 ` Jerry van Dijk
1997-10-20  0:00   ` Anonymous
1997-10-21  0:00     ` Jerry van Dijk
1997-10-20  0:00   ` John English

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