comp.lang.ada
 help / color / mirror / Atom feed
* how to read status of current_output
@ 2018-06-05  9:54 mario.blunk.gplus
  2018-06-05 11:44 ` AdaMagica
  2018-06-05 17:24 ` G. B.
  0 siblings, 2 replies; 8+ messages in thread
From: mario.blunk.gplus @ 2018-06-05  9:54 UTC (permalink / raw)


Hello,

I have a program that frequently changes the current_output (with statement set_output (blabla)). During the course of the program I want to read the status, means the current value of current_output. I tried this code:

handle_1, handle_2 : ada.text_io.file_type;

if ada.text_io.file_type (current_output) = handle_1 then ...

The compiler outputs this:
there is no applicable operator "=" for private type "Ada.Text_Io.File_Type"

I know ada.text_io.file_type is a limited type, which makes using variables in that context impossible.

Is there a more professional way to read the status of current_output ?
Thanks !


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

* Re: how to read status of current_output
  2018-06-05  9:54 how to read status of current_output mario.blunk.gplus
@ 2018-06-05 11:44 ` AdaMagica
  2018-06-06  7:12   ` mario.blunk.gplus
  2018-06-05 17:24 ` G. B.
  1 sibling, 1 reply; 8+ messages in thread
From: AdaMagica @ 2018-06-05 11:44 UTC (permalink / raw)


There is File_Access you could use.
Or Name(Standard_Output), which is a string.


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

* Re: how to read status of current_output
  2018-06-05  9:54 how to read status of current_output mario.blunk.gplus
  2018-06-05 11:44 ` AdaMagica
@ 2018-06-05 17:24 ` G. B.
  2018-06-06  7:14   ` mario.blunk.gplus
  1 sibling, 1 reply; 8+ messages in thread
From: G. B. @ 2018-06-05 17:24 UTC (permalink / raw)


<mario.blunk.gplus@gmail.com> wrote:
> Hello,
> 
> I have a program that frequently changes the current_output (with
> statement set_output (blabla)). During the course of the program I want
> to read the status, means the current value of current_output. I tried this code:
> 
> handle_1, handle_2 : ada.text_io.file_type;
> 
> if ada.text_io.file_type (current_output) = handle_1 then ...

Can you wrap Set_Output in a subprogram that stores the state?


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

* Re: how to read status of current_output
  2018-06-05 11:44 ` AdaMagica
@ 2018-06-06  7:12   ` mario.blunk.gplus
  0 siblings, 0 replies; 8+ messages in thread
From: mario.blunk.gplus @ 2018-06-06  7:12 UTC (permalink / raw)


On Tuesday, June 5, 2018 at 1:44:48 PM UTC+2, AdaMagica wrote:
> There is File_Access you could use.
> Or Name(Standard_Output), which is a string.

Thanks that does the job well. I wrote:
if name (current_output) = name (handle_2) then ...

Thanks !

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

* Re: how to read status of current_output
  2018-06-05 17:24 ` G. B.
@ 2018-06-06  7:14   ` mario.blunk.gplus
  2018-06-06 11:01     ` Marius Amado-Alves
  0 siblings, 1 reply; 8+ messages in thread
From: mario.blunk.gplus @ 2018-06-06  7:14 UTC (permalink / raw)


On Tuesday, June 5, 2018 at 7:24:37 PM UTC+2, G. B. wrote:
> <mario.blunk.gplus@gmail.com> wrote:
> > Hello,
> > 
> > I have a program that frequently changes the current_output (with
> > statement set_output (blabla)). During the course of the program I want
> > to read the status, means the current value of current_output. I tried this code:
> > 
> > handle_1, handle_2 : ada.text_io.file_type;
> > 
> > if ada.text_io.file_type (current_output) = handle_1 then ...
> 
> Can you wrap Set_Output in a subprogram that stores the state?

I was thinking about this approach, but it would introduce another variable that keeps track of the current output. The solution with name (current_output) seems the easiest and most elegant. Thanks anyway !

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

* Re: how to read status of current_output
  2018-06-06  7:14   ` mario.blunk.gplus
@ 2018-06-06 11:01     ` Marius Amado-Alves
  2018-06-06 17:20       ` mario.blunk.gplus
  0 siblings, 1 reply; 8+ messages in thread
From: Marius Amado-Alves @ 2018-06-06 11:01 UTC (permalink / raw)


Status = Name ?!?!?


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

* Re: how to read status of current_output
  2018-06-06 11:01     ` Marius Amado-Alves
@ 2018-06-06 17:20       ` mario.blunk.gplus
  2018-06-06 20:28         ` Randy Brukardt
  0 siblings, 1 reply; 8+ messages in thread
From: mario.blunk.gplus @ 2018-06-06 17:20 UTC (permalink / raw)


On Wednesday, June 6, 2018 at 1:01:51 PM UTC+2, Marius Amado-Alves wrote:
> Status = Name ?!?!?

name (current_output) returns the absolute path and the file name where the output data goes. Something like /home/mike/tmp/dummy.txt. It is not exactly what I was looking for but, however it solves my problem.
The interesting question is: What does name (current_output) return if the current_output is the standard_output ? Under Linux/UNIX one would expect something like /dev/tty... But what under Windows ?

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

* Re: how to read status of current_output
  2018-06-06 17:20       ` mario.blunk.gplus
@ 2018-06-06 20:28         ` Randy Brukardt
  0 siblings, 0 replies; 8+ messages in thread
From: Randy Brukardt @ 2018-06-06 20:28 UTC (permalink / raw)


<mario.blunk.gplus@gmail.com> wrote in message 
news:81876d1e-5b36-40fb-89a4-57d9b1d10662@googlegroups.com...
> On Wednesday, June 6, 2018 at 1:01:51 PM UTC+2, Marius Amado-Alves wrote:
>> Status = Name ?!?!?
>
> name (current_output) returns the absolute path and the file name where 
> the
> output data goes. Something like /home/mike/tmp/dummy.txt. It is not 
> exactly
> what I was looking for but, however it solves my problem.
> The interesting question is: What does name (current_output) return if the
> current_output is the standard_output ? Under Linux/UNIX one would expect
> something like /dev/tty... But what under Windows ?

I don't think there is a standard name, but every Ada compiler ought to use 
something. Janus/Ada gives them device names STI:, STO:, and ERR:. I've also 
seen them given unix-like device paths. So your compare above ought to work.

                                              Randy.


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

end of thread, other threads:[~2018-06-06 20:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05  9:54 how to read status of current_output mario.blunk.gplus
2018-06-05 11:44 ` AdaMagica
2018-06-06  7:12   ` mario.blunk.gplus
2018-06-05 17:24 ` G. B.
2018-06-06  7:14   ` mario.blunk.gplus
2018-06-06 11:01     ` Marius Amado-Alves
2018-06-06 17:20       ` mario.blunk.gplus
2018-06-06 20:28         ` Randy Brukardt

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