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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: GERMAN,ASCII X-Google-Thread: 103376,f954bcd9ffa6c26c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-18 04:12:24 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!enst!enst.fr!not-for-mail From: "Schroeer, Joachim Dr." Newsgroups: comp.lang.ada Subject: Re: Gnat 3.13p: Command_Name RM A.15 Date: Thu, 18 Jan 2001 13:10:26 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C08147.A4153BD0" X-Trace: avanie.enst.fr 979819871 34563 137.194.161.2 (18 Jan 2001 12:11:11 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 18 Jan 2001 12:11:11 +0000 (UTC) Cc: "'christoph.grein@eurocopter.de'" To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2653.19) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:4146 Date: 2001-01-18T13:10:26+01:00 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C08147.A4153BD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hallo Herr Grein, ich habe auch ein kleines Paket, das ich innerhalb eines=20 gr=F6=DFeren Ada95 Projekts unter WinNT/98 zum Scannen der=20 command-line benutzt habe. Es wurde bisher mit ObjectAda=20 und GNAT eingesetzt und sollte auch auf anderen Plattformen=20 laufen. Die function command_name d=FCrfte Ihnen weiterhelfen. Wenn Sie auch das Paket Portable.Standard haben wollen,=20 das im Body benutzt wird, melden Sie sich bitte. P.S. Eurocopter geh=F6rt doch zur EADS. Warum finde ich Ihren=20 Namen dann nicht in unserer internen Mailing-Liste, wo doch=20 die Kollegen von Daimler-Chrysler noch und die von der Casa=20 schon zu sehen sind? Beste Gr=FC=DFe J. Schr=F6er Dr.-Ing. Joachim Schr=F6er EADS Germany GmbH Defense Electronics Dept.: VEE22 W=F6rthstra=DFe 85 D-89070 ULM Telefon: +49 731 392 5993 Christoph Grein schrieb in im = Newsbeitrag: ... > Thanks to all for their responses. >=20 > Randy Brukardt gave me a nice solution (it may not be applicable for = all cases,=20 > but for me, it worked). >=20 > The original question was: >=20 > How do I get the full name of Ada.Command_Line.Command_Name? The = result of > Command_Name is implementation dependent. >=20 > Open the file with the name given by Command_Name, call the Name = function which=20 > by A8.2(22) must return the full name, then close the file again: >=20 > Open (File, in_file, Ada.Command_Line.Command_Name); > Full_Name :=3D Name (File); -- this is the idea only (careful, = string sizes) > Close (File); >=20 > OK, A8.2(22) actually says "should", but Randy confirmed that the = ACATS test for=20 > the full name, so you can rely on this. >=20 > Christoph Grein >=20 >=20 ------_=_NextPart_000_01C08147.A4153BD0 Content-Type: application/octet-stream; name="utilities-command_line.adb" Content-Disposition: attachment; filename="utilities-command_line.adb" -- -*- Mode: Ada -*- -- Filename : utilities-command_line.ads -- Description : Simplifies access on the command_line parameters -- via key strings (options). -- Author : J. Schroeer -- Created On : 18. Feb. 1998 -- Last Modified By: -- Last Modified On: -- Update Count : 1 -- Status : with Ada.Command_Line; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; with Portable.Operating_System; package body Utilities.Command_Line is Dir_Sep : constant String := Portable.Operating_System.Directory_Separator & ""; ---------------------------------------------------------------------------- function Argument(Key : in String) return String is begin for I in 1 .. Ada.Command_Line.Argument_Count - 1 loop if Key = Ada.Command_Line.Argument(I) then return Ada.Command_Line.Argument(I + 1); end if; end loop; return ""; end Argument; ---------------------------------------------------------------------------- function Argument(Key : in String; Default : in String) return String is Arg : constant String := Argument(Key); begin if Arg /= "" then return Arg; else return Default; end if; end Argument; ---------------------------------------------------------------------------- function Argument(Key : in String; Default : in Float'Base) return Float'Base is Arg : constant String := Argument(Key); begin if Arg /= "" then return Float'Value(Arg); else return Default; end if; end Argument; ---------------------------------------------------------------------------- function Argument(Key : in String; Default : in Integer) return Integer is Arg : constant String := Argument(Key); begin if Arg /= "" then return Integer'Value(Arg); else return Default; end if; end Argument; ---------------------------------------------------------------------------- function Has_Argument(Key : in String) return Boolean is begin for I in 1 .. Ada.Command_Line.Argument_Count loop if Key = Ada.Command_Line.Argument(I) then return True; end if; end loop; return False; end Has_Argument; ---------------------------------------------------------------------------- function Command_Name(Full_Path : in Boolean := True) return String is Name : constant String := Ada.Command_Line.Command_Name; begin if Full_Path then return Name; else return Name(Ada.Strings.Fixed.Index(Source => Name, Pattern => Dir_Sep, Going => Ada.Strings.Backward) + 1 .. Name'Last); end if; end Command_Name; ---------------------------------------------------------------------------- function Total_Command_Line(Full_Path : in Boolean := True) return String is Cl : Ada.Strings.Unbounded.Unbounded_String := Ada.Strings.Unbounded.Null_Unbounded_String; use type Ada.Strings.Unbounded.Unbounded_String; begin for I in 1 .. Ada.Command_Line.Argument_Count loop Cl := Cl & " " & Ada.Command_Line.Argument(I); end loop; return Command_Name(Full_Path) & Ada.Strings.Unbounded.To_String(Cl); end Total_Command_Line; ---------------------------------------------------------------------------- end Utilities.Command_Line; ------_=_NextPart_000_01C08147.A4153BD0 Content-Type: application/octet-stream; name="utilities-command_line.ads" Content-Disposition: attachment; filename="utilities-command_line.ads" -- -*- Mode: Ada -*- -- Filename : utilities-command_line.ads -- Description : Simplifies access on the command_line parameters -- via key strings (options). -- Author : J. Schroeer -- Created On : 18. Feb. 1998 -- Last Modified By: -- Last Modified On: -- Update Count : 1 -- Status : package Utilities.Command_Line is -- All functions herein are case-sensitive for "key". function Argument(Key : in String) return String; -- Returns the argument on the command-line preceded by key if key is found, -- the empty string "" otherwise. -- -- Example: If the main is called like -- -- main -file filename -number 10 -- -- then argument("-file") = "filename", argument(key => "-number") = "10", -- argument("-FILE") = "". function Argument(Key : in String; Default : in String) return String; function Argument(Key : in String; Default : in Float'Base) return Float'Base; function Argument(Key : in String; Default : in Integer) return Integer; -- If has_argument(key) then return the string / float'value / integer'value -- of the corresponding argument. -- If not has_argument(key) then return the default. function Has_Argument(Key : in String) return Boolean; -- Returns true if key is an argument an the command_line, false otherwise. function Command_Name(Full_Path : in Boolean := True) return String; -- Returns ada.command_line.command_name if full_path. -- Returns ada.command_line.command_name without path when not full_path. -- ada.command_line.command_name is the full name of the Main-unit. function Total_Command_Line(Full_Path : in Boolean := True) return String; -- Returns the total command_line including command_name and all arguments -- separated by blanks. end Utilities.Command_Line; ------_=_NextPart_000_01C08147.A4153BD0 Content-Type: application/octet-stream; name="utilities.ads" Content-Disposition: attachment; filename="utilities.ads" -- -*- Mode: Ada -*- -- Filename : utilities.ads -- Description : Parent package for Utilities -- Author : J. Schroeer -- Created On : Wed Mar 26 17:25:34 1997 -- Last Modified By: -- Last Modified On: Wed Jul 2 13:41:50 1997 -- Update Count : 2 -- Status : package Utilities is end Utilities; ------_=_NextPart_000_01C08147.A4153BD0--