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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,92640d662fc31a03 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-04 10:03:11 PST Newsgroups: comp.lang.ada Path: newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!chcgil2-snf1.gtei.net!news.gtei.net!newspump.sol.net!nntp.msen.com!uunet!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: howto make system calls (newbie question) X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3AF2DA3E.82A48BD1@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: Mime-Version: 1.0 Date: Fri, 4 May 2001 16:35:10 GMT X-Mailer: Mozilla 4.5 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: newsfeed.google.com comp.lang.ada:7168 Date: 2001-05-04T16:35:10+00:00 List-Id: Lars Lundgren wrote: > > > procedure Command is > > > > function C_System(value : String) return integer; > > pragma Import( > > C, C_System, "system"); > > > > result : integer; > > begin > > result := C_System("pwd "); > > result := C_System(value => "acdsee D:\work\pictures\BP47.jpg "); > > end Command; > > > > Thank you very much! > > That does do the trick for me. > > However i'm rather surprised to see you suggest that I escape ada and > import C-functions. Is it really the case that such a (from my > perspective) basic function can not be done solely in Ada - despite its > extensive libraries? > > I'm not trying to start a flame, i'm just truly surprised. "system" is an OS function provided by some OSes, where it uses the C calling convention [hence the pragma Import (C, ...);]. Here you are creating your own binding to this OS function; it's quite likely your compiler vendor has also provided you another binding to your OS. It's important to remember that Ada was designed for embedded systems, where there may be no OS at all, which is a big part of why this is not part of the language. -- Jeffrey Carter