> < ^ Date: Mon, 26 Oct 1992 20:37:23 +0100
> < ^ From: Martin Schoenert <martin.schoenert@math.rwth-aachen.de >
< ^ Subject: Re: Press any key to continue...

In his article of 14-Oct-92 Michael K Johnson writes

I wrote a gap procedure to print nicely formatted cayley tables of
groups, but I am missing one thing. I want to stop after each screen
page and print "Press any key to continue", wait for any keystroke,
erase those characters, and go on. I can do all that except actually
waiting for a single keypress. Right now, I have written a
unix-specific C program that gets a single character in non-echo mode
and returns that character. Then I have a small function that looks
like this:

GetCont := function ()
  Print("Press any key to continue\c");

In his article of 14-Oct-92 Werner Nickel gives a possible solution

Here is an example of a function that prints the numbers from
1 to 100. The function prints 20 numbers at a time waiting
for the user to press Cntrl-D after having printed 20 numbers:

Print20AtATime := function( )
    local  i;
    for i  in [ 1 .. 100 ]  do
        Print( i, "\n" );
        if i mod 20 = 0  then
            Print( "Press Cntrl-D" );
            Read( "*stdin*" );

The trick is to use the statement Read("*stdin*") in order to
read from standard input. However, I cannot see how one can erase
the "Press Cntrl-D" since GAP produces a newline after it has read

I don't see a way to erase the 'Press Cntr-D'. Besides, I wouldn't bet
that reading <ctr>-'D' as EOF from '*stdin*' will work on the Macintosh.
I will put this item on my TODO list. Actually I think that the extended
file handling facilities will make this possible automatically.

Users here have asked me for a related thing. They want the ability to
paginate the normal GAP output this way. Especially they want to be able
to type 'q' after seeing the first 20 lines, skipping the remaining 1000
lines. This is important when one forgets the second semicolon.


Martin Sch"onert, Martin.Schoenert@Math.RWTH-Aachen.DE, +49 241 804551
Lehrstuhl D f"ur Mathematik, Templergraben 64, RWTH, D 51 Aachen, Germany

> < [top]