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 22:58:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!news1.ebone.net!news.ebone.net!newsrouter.euroconnect.net!newsfeed.song.fi!nntp.inet.fi!central.inet.fi!inet.fi!read2.inet.fi.POSTED!not-for-mail From: "Anders Wirzenius" Newsgroups: comp.lang.ada References: <3C151B2C.4010601@oek.dk> <3C152834.F1B1850F@avercom.net> Subject: Re: Command_Line question X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Message-ID: Date: Tue, 11 Dec 2001 06:57:32 GMT NNTP-Posting-Host: 194.251.142.2 X-Trace: read2.inet.fi 1008053852 194.251.142.2 (Tue, 11 Dec 2001 08:57:32 EET) NNTP-Posting-Date: Tue, 11 Dec 2001 08:57:32 EET Organization: Sonera corp Internet services Xref: archiver1.google.com comp.lang.ada:17732 Date: 2001-12-11T06:57:32+00:00 List-Id: Tucker Taft wrote in message <3C152834.F1B1850F@avercom.net>... >"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. FWIW One of the "more control" things is that Integer_Text_IO.Get(..) will swallow a command line like "Test 3a" or "Test 3." where the Get stops reading at the character "a" or "." The Integer'Value(..) will raise an exception. Neither of them accepts "Test a3". As a newbe to Ada95 myself I have been through the same process as Peter. I want to recommend (as has been done by several persons on cla earlier) studying the generous possibilities that the attributes offer, see http://www.quickreferences.yucom.be/QRC/Ada%20Reference%20Card.pdf Anders Wirzenius