From: Tucker Taft <stt@avercom.net>
Subject: Re: Command_Line question
Date: Mon, 10 Dec 2001 16:25:08 -0500
Date: 2001-12-10T21:24:27+00:00 [thread overview]
Message-ID: <3C152834.F1B1850F@avercom.net> (raw)
In-Reply-To: 3C151B2C.4010601@oek.dk
"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)
next prev parent reply other threads:[~2001-12-10 21:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-10 20:29 Command_Line question Peter I. Hansen
2001-12-10 21:25 ` Tucker Taft [this message]
2001-12-11 6:57 ` Anders Wirzenius
2001-12-11 12:26 ` Peter I. Hansen
2001-12-10 21:53 ` Mark Lundquist
2001-12-11 13:03 ` Marc A. Criley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox