comp.lang.ada
 help / color / mirror / Atom feed
From: "Ken Garlington" <Ken.Garlington@computer.org>
Subject: Re: How to do it in Ada ?
Date: Mon, 16 Jul 2001 17:37:22 GMT
Date: 2001-07-16T17:37:22+00:00	[thread overview]
Message-ID: <mDF47.541$eg1.209154212@newssvr11.news.prodigy.com> (raw)
In-Reply-To: Z9w47.213303$%i7.122829537@news1.rdc1.sfba.home.com

Heck, if I were going to do it the natural Ada way, I'd say:

with Ada.Command_Line;
with Ada.Text_Io; -- for debug only
procedure Main is

   -- N is the first argument, if it is specified and "reasonable".
   -- Otherwise, it defaults to the value 1 (one array element).
   function N return Positive is
      subtype OK_Range is Positive range 1 .. 65_535;
      -- 65,535 can be replaced with whatever is "reasonable"
      -- for an upper limit, or the range eliminated altogether.
   begin
      return OK_Range'Value(Ada.Command_Line.Argument(1));
   exception
      when others =>
         return 1;
   end N;

   X : array (1 .. N) of Integer := (others => 0);

begin

   Ada.Text_Io.Put_Line("Hey! You've got an array of" &
      Natural'Image(X'Length) & " element(s)!");

   -- do what you gotta do

end Main;





      parent reply	other threads:[~2001-07-16 17:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-16  3:33 How to do it in Ada ? Tomasz Wegrzanowski
2001-07-16  5:31 ` Jeffrey Carter
2001-07-16  6:41 ` Al Christians
2001-07-16  6:51 ` tmoran
2001-07-16 16:56   ` Mark Lundquist
2001-07-16 18:42     ` Nonsense (was Re: How to do it in Ada ?) Mark Lundquist
2001-07-16 22:20       ` Jeffrey Carter
2001-07-17  0:13       ` Ken Garlington
2001-07-17  3:53       ` Robert Dewar
2001-07-16 22:18     ` How to do it in Ada ? Jeffrey Carter
2001-07-17  4:06       ` tmoran
2001-07-20  5:39     ` David Thompson
2001-07-16 17:37   ` Ken Garlington [this message]
replies disabled

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