comp.lang.ada
 help / color / mirror / Atom feed
* HELP: Send command to the Windows prompt from Ada procedure
@ 2004-02-25 16:48 Lele
  2004-02-25 18:20 ` David C. Hoos
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Lele @ 2004-02-25 16:48 UTC (permalink / raw)


Hi,
does anyone show me the simplest way to perform a windows system call using
Ada ?
I've to call a batch file from my not-professional Ada procedure, or I've to
send command to the windows prompt (command.com) . How can I do that?
Thanx for the advices.





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

* Re: Send command to the Windows prompt from Ada procedure
  2004-02-25 16:48 HELP: Send command to the Windows prompt from Ada procedure Lele
@ 2004-02-25 18:20 ` David C. Hoos
  2004-02-26  8:50   ` Lele
  2004-02-25 18:27 ` HELP: " tmoran
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: David C. Hoos @ 2004-02-25 18:20 UTC (permalink / raw)
  To: Lele; +Cc: comp.lang.ada@ada.eu.org


----- Original Message ----- 
From: "Lele" <lele@libero.it>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada-france.org>
Sent: Wednesday, February 25, 2004 10:48 AM
Subject: HELP: Send command to the Windows prompt from Ada procedure


> Hi,
> does anyone show me the simplest way to perform a windows system call
using
> Ada ?
> I've to call a batch file from my not-professional Ada procedure, or I've
to
> send command to the windows prompt (command.com) . How can I do that?
> Thanx for the advices.
>
Here is a library-level function that invokes the "system" function
of the C-runtime library.

with Interfaces.C;
function Execute_Shell_Command (Command : in String) return Integer
  is
    function Execute (Command : in Interfaces.C.char_array)
       return Interfaces.C.int;
    pragma Import (C, Execute, "system");
  begin --  Execute_Shell_Command
     return Integer (Run (Interfaces.C.To_C (Item => Command)));
end Execute_Shell_Command;




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

* Re: HELP: Send command to the Windows prompt from Ada procedure
  2004-02-25 16:48 HELP: Send command to the Windows prompt from Ada procedure Lele
  2004-02-25 18:20 ` David C. Hoos
@ 2004-02-25 18:27 ` tmoran
  2004-02-26  9:48 ` Dmitry A. Kazakov
  2004-02-27 13:22 ` Stephen Leake
  3 siblings, 0 replies; 6+ messages in thread
From: tmoran @ 2004-02-25 18:27 UTC (permalink / raw)


>does anyone show me the simplest way to perform a windows system call using
>Ada ?
  That's not part of Ada - it varies a great deal among OSes so it's
normally supplied by the compiler vendor for the particular compiler
and OS.  Look in your docs.  If you're using Gnat, my Gnat docs have
it under Gnat.OS_Lib in the reference manual (not the user guide).



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

* Re: Send command to the Windows prompt from Ada procedure
  2004-02-25 18:20 ` David C. Hoos
@ 2004-02-26  8:50   ` Lele
  0 siblings, 0 replies; 6+ messages in thread
From: Lele @ 2004-02-26  8:50 UTC (permalink / raw)


Great !!!!! It works fine !!!
Thank you
I'm really a newbie ;(



> Here is a library-level function that invokes the "system" function
> of the C-runtime library.
>
> with Interfaces.C;
> function Execute_Shell_Command (Command : in String) return Integer
>   is
>     function Execute (Command : in Interfaces.C.char_array)
>        return Interfaces.C.int;
>     pragma Import (C, Execute, "system");
>   begin --  Execute_Shell_Command
>      return Integer (Run (Interfaces.C.To_C (Item => Command)));
> end Execute_Shell_Command;
>





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

* Re: HELP: Send command to the Windows prompt from Ada procedure
  2004-02-25 16:48 HELP: Send command to the Windows prompt from Ada procedure Lele
  2004-02-25 18:20 ` David C. Hoos
  2004-02-25 18:27 ` HELP: " tmoran
@ 2004-02-26  9:48 ` Dmitry A. Kazakov
  2004-02-27 13:22 ` Stephen Leake
  3 siblings, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2004-02-26  9:48 UTC (permalink / raw)


On Wed, 25 Feb 2004 17:48:54 +0100, "Lele" <lele@libero.it> wrote:

>does anyone show me the simplest way to perform a windows system call using
>Ada ?

There are Win32 bindings for that. If you have a compiler for Windows
you probably have them.

Even if some of API are not listed there it is usually quite easy to
call them manually using pragma Import. For example:

with Interfaces.C;
with Win32.WinDef; use Win32.WinDef;
with Win32.WinNT; use Win32.WinNT;

function LoadImage (Instance : HINSTANCE;  ...) return HANDLE;
pragma Import (StdCall, LoadImage, "LoadImageA");

>I've to call a batch file from my not-professional Ada procedure, or I've to
>send command to the windows prompt (command.com) . How can I do that?

Generally the same way as you would do it in C or Basic.

--
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



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

* Re: HELP: Send command to the Windows prompt from Ada procedure
  2004-02-25 16:48 HELP: Send command to the Windows prompt from Ada procedure Lele
                   ` (2 preceding siblings ...)
  2004-02-26  9:48 ` Dmitry A. Kazakov
@ 2004-02-27 13:22 ` Stephen Leake
  3 siblings, 0 replies; 6+ messages in thread
From: Stephen Leake @ 2004-02-27 13:22 UTC (permalink / raw)
  To: comp.lang.ada

"Lele" <lele@libero.it> writes:

> Hi,
> does anyone show me the simplest way to perform a windows system call using
> Ada ?
> I've to call a batch file from my not-professional Ada procedure, or I've to
> send command to the windows prompt (command.com) . How can I do that?

If you are using GNAT, see gnat.os_lib.spawn.

-- 
-- Stephe




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

end of thread, other threads:[~2004-02-27 13:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-25 16:48 HELP: Send command to the Windows prompt from Ada procedure Lele
2004-02-25 18:20 ` David C. Hoos
2004-02-26  8:50   ` Lele
2004-02-25 18:27 ` HELP: " tmoran
2004-02-26  9:48 ` Dmitry A. Kazakov
2004-02-27 13:22 ` Stephen Leake

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