comp.lang.ada
 help / color / mirror / Atom feed
From: reinkor <reinkor@gmail.com>
Subject: How  to use/obtain output from system commands (in an Ada program) ?
Date: Sat, 18 Jun 2016 23:08:20 -0700 (PDT)
Date: 2016-06-18T23:08:20-07:00	[thread overview]
Message-ID: <226b186b-3ea0-44fc-82cd-97c1e260d368@googlegroups.com> (raw)

Hi,

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

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");
     Open(file1,In_File,"choice_file1");
     declare
      A : String := Get_Line(file1);
     begin
      Put(" Choice: " & A);
     end;
     Close(file1);
end Test7;

Are there more direct/better ways?

** By the way: when I run this program on Raspberry Pi 
(lastest Raspbian jessie) i get, as expected, created the file "choice_file1".
Under OpenSuse Leap 42.1, gnat-5, i get produced a file named:
"choice_file1choice_file1test7.adb". Strange?

reinert

             reply	other threads:[~2016-06-19  6:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-19  6:08 reinkor [this message]
2016-06-19  7:23 ` How to use/obtain output from system commands (in an Ada program) ? Dmitry A. Kazakov
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