comp.lang.ada
 help / color / mirror / Atom feed
* How  to use/obtain output from system commands (in an Ada program) ?
@ 2016-06-19  6:08 reinkor
  2016-06-19  7:23 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 9+ messages in thread
From: reinkor @ 2016-06-19  6:08 UTC (permalink / 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

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

end of thread, other threads:[~2016-06-22  8:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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