comp.lang.ada
 help / color / mirror / Atom feed
From: spiegel@bruessel.informatik.uni-stuttgart.de (Andre Spiegel)
Subject: Re: GOTOXY in Ada ?
Date: Tue, 13 Dec 1994 10:09:21 GMT
Date: 1994-12-13T10:09:21+00:00	[thread overview]
Message-ID: <SPIEGEL.94Dec13110921@berlin.bruessel.informatik.uni-stuttgart.de> (raw)
In-Reply-To: daver@Starbase.NeoSoft.COM's message of 8 Dec 1994 22:19:38 -0600 [ 09 Dec 1994 05:19:38 MET ]

Dave Retherford writes:

  [ suggestion to position the cursor using Text_IO.Set_Col, Set_Line ]

> Of course this will only give you cursor control at a character 
> positioning level.  Also, this works with whatever the standard output 
> file (or rather default one) which in most cases will be the screen (at 
> least it is on the compilers I use).

I wonder if what you say here is clear enough; let me stress that this
is almost certainly not what the original poster wanted, because
Set_Col and Set_Line can only *advance* the cursor, by putting out
whitespace (Blanks and Newlines). So for example, if you want to write
at column 30, but the current "cursor column" happens to be 40, then 

    Set_Col (30);

will move the "cursor" to column 30 on the *next* line. Trying to set
the line number to a value less than the current one causes a form
feed, i.e. a new page is started, and then the "cursor" is moved to
the given line, by putting out Newlines.

Although this works with any text file, I haven't seen any useful
application of it, yet. (Set_Col can be used to create columns of
numbers, or the like; advancing to the next line is sensible if an
entry happens to be wider than the space allowed; but I can hardly 
imagine what Set_Line could be good for.) I still remember my first
Ada program, in which I tried to move the cursor with Text_IO. The
output looked very strange... :-)

So, actual cursor positioning has to be done using the previously
suggested method (escape sequences to the terminal). The sequence
given by Phil Brashear is correct, BTW: 

  Put (Ascii.Esc & "[" & Line_Number_As_String & ";" 
                       & Column_Number_As_String & "H");

Note, however, that the output is (generally?) not flushed if you do
this. Text_IO only flushes after a Newline (and in some other
situations). If you want to see the output immediately, you also have
to look out for a flush procedure -- which is not part of Text_IO, and
can only be implemented "foreignly" (ioctl, for example). Some
compiler vendors supply such a procedure. There also is one the
IEEE Posix binding.

--
Andre Spiegel                     |  This life is a test. It is only a test.
                                  |  Had this been an actual life, you would
University of Stuttgart, Germany  |  have received further instructions as to
Computer Science                  |  where to go and what to do.
                                                            -- Author unknown

	   e-mail: spiegel@bruessel.informatik.uni-stuttgart.de








  parent reply	other threads:[~1994-12-13 10:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-07 12:36 GOTOXY in Ada ? Jan Ahlers
1994-12-08 13:04 ` Philip Brashear
1994-12-09  4:19   ` Dave Retherford
1994-12-12  8:45     ` Keith Thompson
1994-12-13 10:09     ` Andre Spiegel [this message]
1994-12-09  2:59 ` Michael Feldman
1994-12-09 15:22 ` Do-While Jones
1994-12-10 21:00   ` Michael Feldman
  -- strict thread matches above, loose matches on Subject: below --
1994-12-20  2:06 GOTOXY IN ADA ? Michael Hagerty
replies disabled

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