comp.lang.ada
 help / color / mirror / Atom feed
* Re: comand line arguments
@ 1997-10-13  0:00 Marin David Condic, 561.796.8997, M/S 731-96
  0 siblings, 0 replies; 4+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-96 @ 1997-10-13  0:00 UTC (permalink / raw)



    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 ;




^ permalink raw reply	[flat|nested] 4+ messages in thread
* comand line arguments
@ 1997-10-09  0:00 ucs_rat
  1997-10-10  0:00 ` bklungle
  1997-10-10  0:00 ` Pascal Obry
  0 siblings, 2 replies; 4+ messages in thread
From: ucs_rat @ 1997-10-09  0:00 UTC (permalink / raw)



Could some one give me a quick snibbit of code to do simple command line
aruguments in GNAT Ada95.  IF there are any necessary with and use
declartions would you let me know about them too?  It doesn't have to be
complex just some basic commands that cuold be done from batches...just
would rather wrapp is all up in one tight ada program.  

Thanks for the help,

Robert A. Thompson




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-13  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-13  0:00 comand line arguments Marin David Condic, 561.796.8997, M/S 731-96
  -- strict thread matches above, loose matches on Subject: below --
1997-10-09  0:00 ucs_rat
1997-10-10  0:00 ` bklungle
1997-10-10  0:00 ` Pascal Obry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox