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-27 14:11:41 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!pc-62-30-113-100-cr.blueyonder.co.UK!not-for-mail From: nickroberts@ukf.net (Nick Roberts) Newsgroups: comp.lang.ada Subject: Re: How to find directory where the program is? Date: Sat, 27 Apr 2002 21:12:24 GMT Message-ID: <3ccb0c45.64564612@news.cis.dfn.de> References: <3CC6D15A.2070509@mail.com> <3cc73115.426446486@news.cis.dfn.de> <3CC9459E.7A49A4F7@nbi.dk> NNTP-Posting-Host: pc-62-30-113-100-cr.blueyonder.co.uk (62.30.113.100) X-Trace: fu-berlin.de 1019941899 10708768 62.30.113.100 (16 [25716]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:23177 Date: 2002-04-27T21:12:24+00:00 List-Id: On 27 Apr 2002 09:39:03 -0500, Kilgallen@SpamCop.net (Larry Kilgallen) strongly typed: >In article , "Marin David Condic" writes: > >> Most OS's have some means for keeping that kind of thing around somewhere, >> just that it isn't going to be a "portable" answer. Its the sort of thing >> that Ada has been very good at hiding in the past - maybe that's something >> that needs to be in an OS Interface package? > >But sometimes there will not be an answer, if you are expecting a >disk location. On VMS the program you are running might be on >magnetic tape. I think we might consider that a bit of a pathological case, nowadays, Larry! Besides, I think Marin was suggesting a standard way to obtain configuration data (not necessarily anything to do with where the executable is located). May I propose: with Ada.IO_Exceptions; package Ada.Program_Environment is type Mechanism is (...); -- implementation defined enumeration type Default_Mechanism: Mechanism := ...; -- may be initialised statically or dynamically function Get_Item (Name: in Wide_String; Via: in Mechanism := Default_Mechanism) return Wide_String; -- returns "" if item not found procedure Set_Item (Name, Value: in Wide_String; Via: in Mechanism := Default_Mechanism); -- may or may not delete if Value="" procedure Delete_Item (Name: in Wide_String; Via: in Mechanism := Default_Mechanism); -- deletes or (if cannot) sets to "" Name_Error: exception renames Ada.IO_Exceptions.Name_Error; Use_Error: exception renames Ada.IO_Exceptions.Use_Error; Device_Error: exception renames Ada.IO_Exceptions.Device_Error; end Ada.Program_Environment; The different mechanisms for Windows (32-bit) might be: ( Environment_Variables, Windows_INI_File, Program_Home_INI_File, Registry_User, Registry_Local, Registry_System ); Just a thought. PS: The syntax of names is intended to be left implementation-defined (just like file names). However, it might be necessary to single out one punctuation character that must be usable (as a delimiter) with impunity. Perhaps '.' would be best for this. PPS: '=' is likely to be unusable. -- Nick Roberts