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,814d0ec938d6e4da X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-23 12:37:15 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How to find directory where the program is? Date: Tue, 23 Apr 2002 14:37:22 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:23010 Date: 2002-04-23T14:37:22-05:00 List-Id: Preben Randhol wrote in message ... >How can one in Ada95 find out from which directory the Ada program is >stored in. I mean I need to find out if my program is stored in >/usr/bin/ or /usr/local/bin or some other directory. Does anybody know >how I can do this. Note that current directory is not equal to the >directory the program is stored in. I use GNAT so if GNAT has some >routines for this that I have missed, please tell me. I'll make it >portable later if needed. If you want the location that the program is launched from, you want Argv(0) (in C terms). Ada makes this available in Ada.Command_Line.Command_Name. Since this is implementation-defined, it may not include the path on all targets. It does on Windows. The program: with Ada.Text_IO, Ada.Command_Line; procedure Temp is begin Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name); end Temp; prints: E:\TESTING\NT\CONSOLE\TEMP.EXE on my Windows machine with Janus/Ada. (Since Janus/Ada just returns what Windows gives it, I would be surprised if some other Ada compiler didn't return the full path on Windows.) Randy.