comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <mark_h_johnson@raytheon.com>
Subject: Re: Data_Error - Where in this code?
Date: Wed, 08 Aug 2001 08:08:24 -0500
Date: 2001-08-08T08:08:24-05:00	[thread overview]
Message-ID: <3B7139C8.36D68A1D@raytheon.com> (raw)
In-Reply-To: lb12ntcg0di3ego99m8sbqrquffmah1uq9@4ax.com

Stewart wrote:

> On Mon, 06 Aug 2001 20:47:41 +0100, Stewart <s_aitken@lineone.net>
> wrote:
> Hi,
>
> I still get the Max_Size is not declared, but it is not defined until
> the variable for the input is obtained.

And as such - Max_Size cannot be used in an expression prior to its
initialization. The line...
  >      Input     : String (1 .. Max_Size);
is such an expression. It requires the compiler to allocate "Max_Size" bytes of
storage for the "Input" string. Let's say the Ada runtime gave you a default
value of zero (0) for Max_Size - the statement above be equivalent to...
 >      Input     : String (1 .. 0);
which I'm pretty sure is not what you wanted.... If you have something like gvd
(GNU visual debugger), I suggest stepping through the code to illustrate this
concept.

Why not use...
  Max_Size : Positive := 80; -- make it longer than any expected input line
instead. Text_IO.Get_Line will read up to 80 characters from the input line & set
Max_Size to the number of characters read. The rest of the code is pretty user
hostile, but "should work" as you expect.
  --Mark





  reply	other threads:[~2001-08-08 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-06 19:47 Data_Error - Where in this code? Stewart
2001-08-07 13:53 ` Mark Johnson
2001-08-08  9:31 ` Stewart
2001-08-08 13:08   ` Mark Johnson [this message]
2001-08-09  9:34     ` Stewart
2001-08-09 13:27       ` Mark Johnson
2001-08-09 17:55         ` Stewart
replies disabled

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