From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a33ec7badc330d9e X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Ada Equivalent of "system()" in C? Date: 1996/04/16 Message-ID: #1/1 X-Deja-AN: 147932573 sender: tardieu@gargantua.enst.fr references: to: dsparks@pobox.com (Dave Sparks) content-type: text/plain; charset=iso-8859-1 organization: TELECOM Paris mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-16T00:00:00+00:00 List-Id: >>>>> "Dave" == Dave Sparks writes: Dave> I'm new to Ada programming, having come from a C background. Is Dave> there an equivalent in Ada of the "system()" function in C that Dave> allows you execute an external program? Every C library functions may be accessed from an Ada program. All you have to do is put a wrapper on it. Try something like that (untested): +++ GNATCHOP FROM HERE +++ package System_Interface is function System (Command : String) return Integer; end System_Interface; with Interfaces.C.Strings; use Interfaces.C; use Interfaces.C.Strings; package body System_Interface is function System (Command : String) return Integer is function C_System (Command : chars_ptr) return int; pragma import (C, C_System, "system"); C_Command : chars_ptr := New_String (Command); Return_Code : constant int := C_System (C_Command); begin Free (C_Command); return Integer (Return_Code); end System; end System_Interface; +++ GNATCHOP TO HERE +++ Then you may call: R_Code := System_Interface.System (My_Command); Hope this helps. Sam -- "La cervelle des petits enfants, ca doit avoir comme un petit gout de noisette" Charles Baudelaire