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,9384451580450d27 X-Google-Attributes: gid103376,public From: "Marin David Condic, 561.796.8997, M/S 731-96" Subject: Re: comand line arguments Date: 1997/10/13 Message-ID: <97101310345365@psavax.pwfl.com>#1/1 X-Deja-AN: 280230023 Sender: Ada programming language Comments: To: ucs_rat@shsu.edu X-VMS-To: SMTP%"INFO-ADA@VM1.NODAK.EDU" X-VMS-Cc: SMTP%"ucs_rat@SHSU.EDU",CONDIC Newsgroups: comp.lang.ada Date: 1997-10-13T00:00:00+00:00 List-Id: Here's some code that should at least get you started developing whatever you need for processing a command line. MDC Marin David Condic, Senior Computer Engineer Voice: 561.796.8997 Pratt & Whitney GESP, M/S 731-96, P.O.B. 109600 Fax: 561.796.4669 West Palm Beach, FL, 33410-9600 Internet: CONDICMA@PWFL.COM =============================================================================== "Eagles may soar, but a weasle never gets sucked up into a jet engine." =============================================================================== -- -- This function will return a string containing everything that -- was on the command line. Due to OS pecularities, you may not -- get it back exactly as typed. You may not get everything you -- want, either. Ada can't fix that because it's going to depend on -- what the OS decides to give you. From experience, Unix and WinNT -- will produce different effects from the same code. -- -- A lot of this implementation depends on what sort of command line -- "language" you intend to be parsing out of the string. You'll -- have to tailor the function as needed, but it at least -- illustrates the proper calls to Ada.Command_Line. -- -- The function presumes that you don't care about spaces between -- parameters. You could modify it to put spaces between the -- parameters, etc. -- with Ada.Command_Line ; with Ada.Strings ; with Ada.Strings.Maps ; with Ada.Strings.Fixed ; with Ada.Characters.Handling ; with Ada.Text_IO ; function Get_Command_Line return String is -- Temp : String (1..256) := (others => ' ') ; I : Natural := 0 ; -- use Ada.Command_Line ; use Ada.Strings.Fixed ; begin -- -- Get the "command" or program name from the system if available. -- Ada.Strings.Fixed.Move ( Source => Ada.Command_Line.Command_Name, Target => Temp, Drop => Ada.Strings.Right) ; -- -- Get each of the args into the string - spaces don't matter. -- I := Ada.Strings.Fixed.Index ( Source => Temp, Pattern => " ") ; for X in 1..Ada.Command_Line.Argument_Count loop Ada.Strings.Fixed.Move ( Source => Ada.Command_Line.Argument (X), Target => Temp (I..Temp'Last), Drop => Ada.Strings.Right) ; I := Index_Non_Blank ( Source => Temp, Going => Ada.Strings.Backward) + 1 ; end loop ; -- return Ada.Strings.Fixed.Trim ( Source => Temp, Side => Ada.Strings.Both) ; exception when Constraint_Error => Ada.Text_IO.Put_Line ("Your command line is probably too long.") ; return "" ; end Get_Command_Line ;