comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado-Alves <amado.alves@gmail.com>
Subject: Re: How to call a Windows executable from Ada?
Date: Thu, 9 Dec 2021 01:28:59 -0800 (PST)	[thread overview]
Message-ID: <c476b633-3a86-4526-95e6-f29ddfc6d7f1n@googlegroups.com> (raw)
In-Reply-To: <sosb8g$1hb5$1@gioia.aioe.org>

Thanks all.

Yeah, it's probably the quotation marks. I found no way around it with GNAT.OS_Lib. The quotes are needed because the names have spaces.

Only way I found that works is with the command inside a .BAT file, then call that with GNAT.OS_Lib.Spawn

   Arguments : Argument_List :=
                 (  1=> new String'("C:\Test\save_as_txt.bat"),
                    2=> new String'("")
                 );
begin
   Spawn
   (  Program_Name           => "C:\Test\save_as_txt.bat",
      Args                   => Arguments,
      Output_File_Descriptor => Standout,
      Return_Code            => Result
   );

Also the BAT file *must* start with the magic incantation

chcp 65001

on the first line, in order for the accented characters to work.

So, a pragmatical solution exists, but ugly and irritating and hard to find.
Hope these tips may save someone as many hours as I wasted with OS_Lib nonsense.
Still a clean documented solution is to be found.
Share your good code.

  reply	other threads:[~2021-12-09  9:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 23:04 How to call a Windows executable from Ada? Marius Amado-Alves
2021-12-09  5:09 ` Randy Brukardt
2021-12-09  7:26 ` Vadim Godunko
2021-12-09  7:29 ` Dmitry A. Kazakov
2021-12-09  9:28   ` Marius Amado-Alves [this message]
2021-12-09 18:38     ` Dennis Lee Bieber
2021-12-09 19:27     ` Dmitry A. Kazakov
replies disabled

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