comp.lang.ada
 help / color / mirror / Atom feed
* TEXT_IO anomality
@ 1990-07-25  7:03 "Jonathan B. Owen"
  1990-07-25 17:14 ` Charles H. Sampson
  0 siblings, 1 reply; 8+ messages in thread
From: "Jonathan B. Owen" @ 1990-07-25  7:03 UTC (permalink / raw)



1. When using TEXT_IO procedures and function without a file parameter,
   STANDARD_INPUT and STANDARD_OUTPUT are used according to the
   type of service (i.e. Get or Put, mainly).

   Unlike the clarity of the above defaults, the SET_COL and COL
   functions apply both to standard input and output.  As far as
   I know, these services without a file parameter default to
   STANDARD_OUTPUT.  Is this mentioned or defined in the LRM?

2. When doing a Get_line, the user terminates input by pressing <CR>.
   This moves the screen cursor to Col 1 of the following line (and
   the COL counter of STANDARD_INPUT is updated accordingly).  Still,
   the COL counter of STANDARD_OUTPUT remains as before.  This causes
   a difficulty when output relys on first obtaining this value and
   using it for printing multiple lines at specific column.  Since
   first line is printed at column 1 even though counter is not so.
   Attempting to do a TEXT_IO.SET_COL( TEXT_IO.COL ) will not work,
   since this will have no effect.

   Also, if you would like to correct the COL counter of STANDARD_OUTPUT
   by doing SET_COL(1), so it will be in accord to the screen cursor,
   you will result with a blank line (assuming that the counter was
   greater than 1).

   Here's a demonstrations of the problem:

        Put("Prompt> ");  Get_line(buffer, last_pos);

        declare
            c : TEXT_IO.Count := TEXT_IO.COL;
        begin
            for i in 1..5
            loop
                -- Adding here Set_col(c) will do nothin in Verdix Ada
                -- since delta between c and TEXT_IO.COL is zero!

                Put_line("All lines should start from same column!");
                TEXT_IO.Set_col(c);
            end loop;
        end;

    Output will look like this:

        Prompt> Humph <CR>
        All lines should start from same column!
                All lines should start from same column!
                All lines should start from same column!
                All lines should start from same column!
                All lines should start from same column!


                        Any thoughts? Comments?  Suggestions?

                                    Jonathan B. Owen

______________________________________________________________________________
  (--)    /--)     /-(\                 Email: gdau100@bguvm (bitnet)
  \ /    /--K      | \|/\   /\/) /|-\   Snail: 55 Hovevei Zion
  _/_/o /L__)_/o \/\__/  \X/  \_/ | |_/        Tel-Aviv, 63346  ISRAEL
 (/        Jonathan B. Owen             Voice: (03) 281-422

 Point of view:  A chicken is the means by which an egg reproduces an egg.
______________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread
* TEXT_IO anomality
@ 1990-07-26 14:32 "", Mats Weber
  0 siblings, 0 replies; 8+ messages in thread
From: "", Mats Weber @ 1990-07-26 14:32 UTC (permalink / raw)


RFC-822-Headers:
Received: from elcgl.epfl.ch by SIC.Epfl.CH with VMSmail ; Thu, 26 Jul 90 15:32:38 N
X-ST-Vmsmail-To: gw::"info-ada@ajpo.sei.cmu.edu"
gw::"gdau100@bguvm"

==================
>   Here's a demonstrations of the problem:
> 
>        Put("Prompt> ");  Get_line(buffer, last_pos);
> 
>        declare
>            c : TEXT_IO.Count := TEXT_IO.COL;
>        begin
>            for i in 1..5
>            loop
>                -- Adding here Set_col(c) will do nothin in Verdix Ada
>                -- since delta between c and TEXT_IO.COL is zero!
> 
>                Put_line("All lines should start from same column!");
>                TEXT_IO.Set_col(c);
>            end loop;
>        end;
> 
>    Output will look like this:
> 
>        Prompt> Humph <CR>
>        All lines should start from same column!
>                All lines should start from same column!
>                All lines should start from same column!
>                All lines should start from same column!
>                All lines should start from same column!
> 
> 
>                        Any thoughts? Comments?  Suggestions?
> 
>                                    Jonathan B. Owen

This behavior is required by the LRM because the page, line and column 
counts are a property of the internal file object, not the external file 
(which, in this case, is the terminal).

The preceding piece of code actually manipulates two file objects 
(Current_Output and Current_Input) which are independant from the point of 
view of the Ada program, but are associated with the same external device 
(the terminal). As a consequence, reading "Humph" from Current_Input does 
not change the column count of Current_Output.

Note that the language does not even require that Puts to Current_Output 
and Gets from Current_Input be synchronized, i.e. the string "Prompt> " 
might not appear before the call to Get_Line.

I don't think Text_IO is well suited for reading/writing to or from a 
terminal.

Mats Weber
Swiss Federal Institute of Technology
EPFL DI LGL
1015 Lausanne
Switzerland

E-mail : madmats@elcgl.epfl.ch
phone  : +41 21 693 52 92
fax    : +41 21 693 39 09

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

end of thread, other threads:[~1990-08-13  9:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-07-25  7:03 TEXT_IO anomality "Jonathan B. Owen"
1990-07-25 17:14 ` Charles H. Sampson
1990-07-26  6:54   ` Paul Hilfinger
1990-07-26 15:02     ` Vinod Grover
1990-07-28  1:20       ` Danford Lehman
1990-08-06 19:44     ` Charles H. Sampson
1990-08-13  9:32       ` Mike Harrison
  -- strict thread matches above, loose matches on Subject: below --
1990-07-26 14:32 "", Mats Weber

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