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,b623fee799cb68b3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-10 13:25:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Command_Line question Date: Mon, 10 Dec 2001 16:25:08 -0500 Organization: AverCom Corp, a Titan company Message-ID: <3C152834.F1B1850F@avercom.net> References: <3C151B2C.4010601@oek.dk> NNTP-Posting-Host: 192.168.24.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 1008019467 57 192.168.24.34 (10 Dec 2001 21:24:27 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 10 Dec 2001 21:24:27 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:17717 Date: 2001-12-10T21:24:27+00:00 List-Id: "Peter I. Hansen" wrote: > > Hello > > I'm new to Ada95, and I'm trying to write a program which needs to read > arguments from the command line. I found out that the Command_Line > package is the way to go, but something i don't get. for example if I > have this code : > > WITH Ada.Text_IO; > WITH Ada.Command_Line; > WITH Ada.Integer_Text_IO; > > PROCEDURE Test IS > > Num : Natural ; > NumLength : Natural ; > > BEGIN -- Test > Ada.Integer_text_IO.Get( From => Ada.Command_Line.Argument(Number => 1), > Item => Num, > Last => NumLenght); Generally, it is easier to use "Integer'Value(blah)" than "Integer_Text_IO.Get(...)". Integer_Text_IO gives you more control, but Integer'Value is usually adequate. So you could change this to: Num := Integer'Value(Ada.Command_Line.Argument(Number => 1)); > Ada.Integer_Text_IO.Put(Item => Num); > > END Test; > > The question is : Is there a way to do this whitout the 'NumLength' > variable, or is this just the way things work ? > > /Peter -- -Tucker Taft stt@avercom.net http://www.avercom.net Chief Technology Officer, AverCom Corporation (A Titan Company) Bedford, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/~stt)