comp.lang.ada
 help / color / mirror / Atom feed
* TEXT_IO
@ 1988-05-11 16:46 Marcus Moehrmann
  0 siblings, 0 replies; 12+ messages in thread
From: Marcus Moehrmann @ 1988-05-11 16:46 UTC (permalink / raw)


Hello,
I have a question concerning TEXT_IO. Consider the following program:

with TEXT_IO;
use  TEXT_IO;
procedure TEST is
begin
--   SET_INPUT  (STANDARD_INPUT);    -- (1)
--   SET_OUTPUT (STANDARD_OUTPUT);   -- (1)
   DO_SOMETHING;
   PUT_LINE ("After doing something");   -- (2)
end TEST;

Now, LRM 14.3(5) states, that the standard IO files are open *at the
beginning* of the program execution and have the appropriate modes.

But what has to be done, if they cannot be opened because of
NAME_ERROR or USE_ERROR ? E.g. with VAX/VMS you can do the following:
   $ DEFINE ADA$OUTPUT <filename-which-raises-io-error-at-TEXT_IO.CREATE>
and something equal for ADA$INPUT. After that STANDARD_OUTPUT cannot
be opened at the beginning of the program execution. I think, the same
can be done in other operating-systems like UNIX or MS/DOS.

Now the question is, *when* to raise the IO error, e.g. NAME_ERROR ?
During elaboration of TEXT_IO, at first use of STANDARD_IO ?

This is what happens with VAX Ada V1.4-33:

   If statements (1) are active, NAME_ERROR will be raised here 

   If statement (1) are commented out, NAME_ERROR will be raised at (2),
   after doing something else.
   
Therefor in Vax Ada statements (1) are neccessary to prevent doing
something after the beginning of the program execution but befor an IO
statement is reached. I feel, that there must not be a difference if
statements (1) are active or not (commented out).


*** Marcus Moehrmann                |  UUCP:    marcus@fkihh.UUCP ***
*** (TeX: M\"{o}hrmann)             |  PHONE:   +49-40-4123-2573  ***
*** Univ of Hamburg, W. Germany     |           +49-40-5202464    ***

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

* Text IO
@ 1995-04-22  0:00 Chris O'Regan
  1995-04-22  0:00 ` Tore Joergensen
  0 siblings, 1 reply; 12+ messages in thread
From: Chris O'Regan @ 1995-04-22  0:00 UTC (permalink / raw)



   I have two questions:

	1) When writing to a file, how can I force the output to be
	   written immediately so that I may monitor the program's
	   progress using ``tail -f'' on the file?


	2) Is it possible to get a single key?  If I use Text_IO's
	   ``Get'' function the user is required to press the enter
	   key after typing the appropriate key.  This is somewhat
	   inconvenient.


   Thanks, in advance, for the help.

-- 
     ____________________________________________________________
              Chris O'Regan <ct_orega@ECE.Concordia.CA>
     Computer Engineering, Concordia University, Montreal, Canada
           http://www.ECE.Concordia.CA/~ct_orega/addr.html




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

* Re: Text IO
  1995-04-22  0:00 Chris O'Regan
@ 1995-04-22  0:00 ` Tore Joergensen
  0 siblings, 0 replies; 12+ messages in thread
From: Tore Joergensen @ 1995-04-22  0:00 UTC (permalink / raw)


Chris O'Regan (ct_oreg@vega.concordia.ca) wrote:

:    I have two questions:
If you use Ada83 I don't think you can do it. If you use Ada95 you just:
: 	1) When writing to a file, how can I force the output to be
: 	   written immediately so that I may monitor the program's
: 	   progress using ``tail -f'' on the file?
ada.text_io.flush(file);

: 	2) Is it possible to get a single key?  If I use Text_IO's
: 	   ``Get'' function the user is required to press the enter
: 	   key after typing the appropriate key.  This is somewhat
: 	   inconvenient.
ada.text_io.get_immediate(char_var);

--
______________________________________________________________________
Tore B. Joergensen,    |    e-mail:     tore@lis.pitt.edu
a norwegian student    |    snail-mail: 2201 Pittockstr.
a long way from home.  |                Pittsburgh, 15217 PA
                       |    web:        http://www.pitt.edu/~tojst1




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

* Text IO
@ 2001-08-28 16:19 Matt Raikes
  2001-08-28 16:28 ` martin.m.dowie
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Matt Raikes @ 2001-08-28 16:19 UTC (permalink / raw)


I was wondering how to convert integers and floats to strings for
output to text files...someone already suggested the following:

For convert Integers to/from Strings check out the
attributes 'Image (to) and 'Value (from)

I couldn't get this to work though.  Any other ideas??

thanks



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

* Re: Text IO
  2001-08-28 16:19 Text IO Matt Raikes
@ 2001-08-28 16:28 ` martin.m.dowie
  2001-08-28 16:47 ` Marin David Condic
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: martin.m.dowie @ 2001-08-28 16:28 UTC (permalink / raw)


"Matt Raikes" <mraikes@vt.edu> wrote in message
news:ab21b49a.0108280819.7483865c@posting.google.com...
> I was wondering how to convert integers and floats to strings for
> output to text files...someone already suggested the following:
>
> For convert Integers to/from Strings check out the
> attributes 'Image (to) and 'Value (from)
>
> I couldn't get this to work though.  Any other ideas??

You didn't take the "(to)" and "(from)" to indicate parameters did you?!
They were ment to indicate the direction of the conversion (although
they could be parameters, if you have assigned the right types...).

I notice you have a virginia tech e-mail address, so I don't want to give
a whole answer away here (do you have a tutor who could help?).






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

* Re: Text IO
  2001-08-28 16:19 Text IO Matt Raikes
  2001-08-28 16:28 ` martin.m.dowie
@ 2001-08-28 16:47 ` Marin David Condic
  2001-08-28 18:33 ` Ted Dennison
  2001-08-29  8:50 ` John McCabe
  3 siblings, 0 replies; 12+ messages in thread
From: Marin David Condic @ 2001-08-28 16:47 UTC (permalink / raw)


You aren't being very specific here. Try posting some of your code and error
messages from the compiler, etc. It is a good idea to provide as much
information as you can about what is not working when posting to a
newsgroup. (Typically, post the compiler + version you are using and the
machine/OS + version you are using just for starters. Code snippets and
error messages from the compiler are also very helpful.)

Commonly, if you are using Text_IO, you would do it sort of like this:

Ada.Text_IO.Put_Line ("Some Number: " & Integer'Image (X)) ;

You have to state the type to which the attribute applies - hence the
Integer'Image (or Float'Image or Natural'Image or Boolean'Image)

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Matt Raikes" <mraikes@vt.edu> wrote in message
news:ab21b49a.0108280819.7483865c@posting.google.com...
> I was wondering how to convert integers and floats to strings for
> output to text files...someone already suggested the following:
>
> For convert Integers to/from Strings check out the
> attributes 'Image (to) and 'Value (from)
>
> I couldn't get this to work though.  Any other ideas??
>
> thanks





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

* Re: Text IO
  2001-08-28 16:19 Text IO Matt Raikes
  2001-08-28 16:28 ` martin.m.dowie
  2001-08-28 16:47 ` Marin David Condic
@ 2001-08-28 18:33 ` Ted Dennison
  2001-08-29  8:50 ` John McCabe
  3 siblings, 0 replies; 12+ messages in thread
From: Ted Dennison @ 2001-08-28 18:33 UTC (permalink / raw)


In article <ab21b49a.0108280819.7483865c@posting.google.com>, Matt Raikes
says...
>For convert Integers to/from Strings check out the
>attributes 'Image (to) and 'Value (from)
>
>I couldn't get this to work though.  Any other ideas??

Try again.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



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

* Re: Text IO
  2001-08-28 16:19 Text IO Matt Raikes
                   ` (2 preceding siblings ...)
  2001-08-28 18:33 ` Ted Dennison
@ 2001-08-29  8:50 ` John McCabe
  2001-09-01  1:15   ` Robert Dewar
  3 siblings, 1 reply; 12+ messages in thread
From: John McCabe @ 2001-08-29  8:50 UTC (permalink / raw)


On 28 Aug 2001 09:19:31 -0700, mraikes@vt.edu (Matt Raikes) wrote:

>I was wondering how to convert integers and floats to strings for
>output to text files...someone already suggested the following:
>
>For convert Integers to/from Strings check out the
>attributes 'Image (to) and 'Value (from)
>
>I couldn't get this to work though.  Any other ideas??

Depends on what you're trying to do. If you're trying to assign them
to a string it is awkward to use 'Image. Perhaps you should look at
the Reference Manual, particularly the section of Integer_IO (or
Integer_Text_IO) that defines the operations Get and Put, where the
first parameter name is "To". These operations allow you to have full
control over the representation of the output data and store it into a
string, similar to sprintf in C.

The 'Image and 'Value attribute results are, I believe, implementation
dependant.


Best Regards
John McCabe



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

* Re: Text IO
  2001-08-29  8:50 ` John McCabe
@ 2001-09-01  1:15   ` Robert Dewar
  2001-09-03  8:23     ` John McCabe
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Dewar @ 2001-09-01  1:15 UTC (permalink / raw)


john.mccabe@emrad.com.nospam (John McCabe) wrote in message news:<3b8cac5b.3843987@news.demon.co.uk>...
> On 28 Aug 2001 09:19:31 -0700, mraikes@vt.edu (Matt Raikes) wrote:
> 
> The 'Image and 'Value attribute results are, I believe, 
> implementation dependant.

That is incorrect, the semantics are fully
defined in the RM.



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

* Re: Text IO
  2001-09-01  1:15   ` Robert Dewar
@ 2001-09-03  8:23     ` John McCabe
  2001-09-03 11:11       ` David C. Hoos, Sr.
  0 siblings, 1 reply; 12+ messages in thread
From: John McCabe @ 2001-09-03  8:23 UTC (permalink / raw)


On 31 Aug 2001 18:15:37 -0700, dewar@gnat.com (Robert Dewar) wrote:

>john.mccabe@emrad.com.nospam (John McCabe) wrote in message news:<3b8cac5b.3843987@news.demon.co.uk>...
>> On 28 Aug 2001 09:19:31 -0700, mraikes@vt.edu (Matt Raikes) wrote:
>> 
>> The 'Image and 'Value attribute results are, I believe, 
>> implementation dependant.
>
>That is incorrect, the semantics are fully
>defined in the RM.

Of course, but I was thinking of floating point numbers in particular
at the time of writing where the image depends on S'Digits. As base
subtypes of float have a 'Digits attribute depending on 'Machine_Radix
and 'Model_Mantissa there is clearly some implementation dependence
here.

I have found that, in general, 'Image is ideal for printing out
information for trace and debug purposes, but you really need to use
the xxx_IO facilities to get fine control over your output
representation.

Best Regards
John McCabe



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

* Re: Text IO
  2001-09-03  8:23     ` John McCabe
@ 2001-09-03 11:11       ` David C. Hoos, Sr.
  2001-09-03 12:05         ` John McCabe
  0 siblings, 1 reply; 12+ messages in thread
From: David C. Hoos, Sr. @ 2001-09-03 11:11 UTC (permalink / raw)
  To: comp.lang.ada

I would call this a machine dependence, not an implementation
dependence.  All implementations, in order to be compliant
would need to produce the same result on the same machine.

----- Original Message -----
From: "John McCabe" <john.mccabe@emrad.com.nospam>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: September 03, 2001 3:23 AM
Subject: Re: Text IO


On 31 Aug 2001 18:15:37 -0700, dewar@gnat.com (Robert Dewar) wrote:

>john.mccabe@emrad.com.nospam (John McCabe) wrote in message
news:<3b8cac5b.3843987@news.demon.co.uk>...
>> On 28 Aug 2001 09:19:31 -0700, mraikes@vt.edu (Matt Raikes) wrote:
>>
>> The 'Image and 'Value attribute results are, I believe,
>> implementation dependant.
>
>That is incorrect, the semantics are fully
>defined in the RM.

Of course, but I was thinking of floating point numbers in particular
at the time of writing where the image depends on S'Digits. As base
subtypes of float have a 'Digits attribute depending on 'Machine_Radix
and 'Model_Mantissa there is clearly some implementation dependence
here.

I have found that, in general, 'Image is ideal for printing out
information for trace and debug purposes, but you really need to use
the xxx_IO facilities to get fine control over your output
representation.

Best Regards
John McCabe
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada





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

* Re: Text IO
  2001-09-03 11:11       ` David C. Hoos, Sr.
@ 2001-09-03 12:05         ` John McCabe
  0 siblings, 0 replies; 12+ messages in thread
From: John McCabe @ 2001-09-03 12:05 UTC (permalink / raw)


On Mon, 3 Sep 2001 06:11:27 -0500, "David C. Hoos, Sr."
<david.c.hoos.sr@ada95.com> wrote:

>I would call this a machine dependence, not an implementation
>dependence.  All implementations, in order to be compliant
>would need to produce the same result on the same machine.

Sounds reasonable!

Best Regards
John McCabe



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

end of thread, other threads:[~2001-09-03 12:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-28 16:19 Text IO Matt Raikes
2001-08-28 16:28 ` martin.m.dowie
2001-08-28 16:47 ` Marin David Condic
2001-08-28 18:33 ` Ted Dennison
2001-08-29  8:50 ` John McCabe
2001-09-01  1:15   ` Robert Dewar
2001-09-03  8:23     ` John McCabe
2001-09-03 11:11       ` David C. Hoos, Sr.
2001-09-03 12:05         ` John McCabe
  -- strict thread matches above, loose matches on Subject: below --
1995-04-22  0:00 Chris O'Regan
1995-04-22  0:00 ` Tore Joergensen
1988-05-11 16:46 TEXT_IO Marcus Moehrmann

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