comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to use/obtain output from system commands (in an Ada program) ?
Date: Sun, 19 Jun 2016 09:23:59 +0200
Date: 2016-06-19T09:23:59+02:00	[thread overview]
Message-ID: <nk5hat$89q$1@gioia.aioe.org> (raw)
In-Reply-To: 226b186b-3ea0-44fc-82cd-97c1e260d368@googlegroups.com

On 2016-06-19 08:08, reinkor wrote:

> I am looking for a simple way to obtain output from "xmessage"
> (or dialog/kdialog) in my Ada program. Any good hints?

The package System.OS_Lib has procedures Spawn that are much more 
comfortable to use than system().

If you use GtkAda you can start xmessage or any other process with 
pipe-lined input/output/error. Then you will have callbacks to process 
them. It is also possible to use Gtk_Text_Buffer instead of callbacks.

http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#10.1

> A trivial way is to output to a file like in this test procedure:
>
> with Interfaces.C;
> with Interfaces.C.Strings;
> with Ada.Text_IO, Text_IO;
>
> procedure Test7 is
>    package C renames Interfaces.C;
>    use type C.char_array;
>    procedure system (Source : in  C.char_array);
>    pragma Import(C, system, "system");
>    use Ada.Text_IO, Text_IO;
>    file1 : File_Type;
> begin
>      system("xmessage -center Box1  -buttons label1:X,label2:y -print > choice_file1");

Add terminating ASCII NUL here.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2016-06-19  7:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-19  6:08 How to use/obtain output from system commands (in an Ada program) ? reinkor
2016-06-19  7:23 ` Dmitry A. Kazakov [this message]
2016-06-20  8:34   ` reinkor
2016-06-20  8:44     ` Dmitry A. Kazakov
2016-06-20  9:22       ` reinkor
2016-06-20  9:59         ` Dmitry A. Kazakov
2016-06-20 19:25           ` reinkor
2016-06-20 19:55             ` Dmitry A. Kazakov
2016-06-22  8:14   ` briot.emmanuel
replies disabled

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